wxc_sdk.messages package

Messages API

class wxc_sdk.messages.AdaptiveCardAction(*, type: Optional[str] = None, url: Optional[str] = None, title: Optional[str] = None)[source]

Bases: ApiModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

type: Optional[str]

Action.OpenUrl

Type

Possible values

url: Optional[str]

//adaptivecards.io

Type

Possible values

Type

http

title: Optional[str]

Learn More

Type

Possible values

class wxc_sdk.messages.AdaptiveCard(*, type: Optional[str] = None, version: Optional[str] = None, body: Optional[list[wxc_sdk.messages.AdaptiveCardBody]] = None, actions: Optional[list[wxc_sdk.messages.AdaptiveCardAction]] = None)[source]

Bases: ApiModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

type: Optional[str]

Must be AdaptiveCard.

version: Optional[str]

Adaptive Card schema version.

body: Optional[list[wxc_sdk.messages.AdaptiveCardBody]]

The card’s elements.

actions: Optional[list[wxc_sdk.messages.AdaptiveCardAction]]

The card’s actions.

class wxc_sdk.messages.MessageAttachment(*, contentType: Optional[str] = None, content: Optional[AdaptiveCard] = None)[source]

Bases: ApiModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

content_type: Optional[str]

The content type of the attachment.

content: Optional[AdaptiveCard]

Adaptive Card content.

class wxc_sdk.messages.AdaptiveCardBody(*, type: Optional[str] = None, text: Optional[str] = None, size: Optional[str] = None)[source]

Bases: ApiModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

type: Optional[str]

TextBlock

Type

Possible values

text: Optional[str]

Adaptive Cards

Type

Possible values

size: Optional[str]

large

Type

Possible values

class wxc_sdk.messages.Message(*, id: Optional[str] = None, parentId: Optional[str] = None, roomId: Optional[str] = None, roomType: Optional[RoomType] = None, text: Optional[str] = None, markdown: Optional[str] = None, html: Optional[str] = None, files: Optional[list[str]] = None, personId: Optional[str] = None, personEmail: Optional[str] = None, toPersonId: Optional[str] = None, toPersonEmail: Optional[str] = None, mentionedPeople: Optional[list[str]] = None, mentionedGroups: Optional[list[str]] = None, attachments: Optional[list[wxc_sdk.messages.MessageAttachment]] = None, created: Optional[datetime] = None, updated: Optional[datetime] = None, isVoiceClip: Optional[bool] = None)[source]

Bases: ApiModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

id: Optional[str]

The unique identifier for the message.

parent_id: Optional[str]

The unique identifier for the parent message.

room_id: Optional[str]

The room ID of the message.

room_type: Optional[RoomType]

The type of room.

text: Optional[str]

The message, in plain text. If markdown is specified this parameter may be optionally used to provide alternate text for UI clients that do not support rich text. The maximum message length is 7439 bytes.

markdown: Optional[str]

The message, in Markdown format. If this attribute is set ensure that the request does NOT contain an html attribute.

html: Optional[str]

The text content of the message, in HTML format. This read-only property is used by the Webex clients.

files: Optional[list[str]]

Public URLs for files attached to the message. For the supported media types and the behavior of file uploads, see Message Attachments.

person_id: Optional[str]

The person ID of the message author.

person_email: Optional[str]

The email address of the message author.

to_person_id: Optional[str]

1 message.

Type

The person ID of the recipient when sending a private 1

to_person_email: Optional[str]

1 message.

Type

The email address of the recipient when sending a private 1

mentioned_people: Optional[list[str]]

People IDs for anyone mentioned in the message.

mentioned_groups: Optional[list[str]]

Group names for the groups mentioned in the message.

attachments: Optional[list[wxc_sdk.messages.MessageAttachment]]

Message content attachments attached to the message. See the Cards Guide for more information.

created: Optional[datetime]

The date and time the message was created.

updated: Optional[datetime]

The date and time that the message was last edited by the author. This field is only present when the message contents have changed.

is_voice_clip: Optional[bool]

true if the audio file is a voice clip recorded by the client; false if the audio file is a standard audio file not posted using the voice clip feature.

class wxc_sdk.messages.MessagesApi(*, session: RestSession, base: Optional[str] = None)[source]

Bases: ApiChild

list(room_id: str, parent_id: Optional[str] = None, mentioned_people: Optional[List[str]] = None, before: Optional[datetime] = None, before_message: Optional[str] = None, **params) Generator[Message, None, None][source]

Lists all messages in a room. Each message will include content attachments if present. The list sorts the messages in descending order by creation date. Long result sets will be split into pages.

Parameters
  • room_id (str) – List messages in a room, by ID.

  • parent_id (str) – List messages with a parent, by ID.

  • mentioned_people (List[str]) – List messages with these people mentioned, by ID. Use me as a shorthand for the current API user. Only me or the person ID of the current user may be specified. Bots must include this parameter to list messages in group rooms (spaces).

  • before (str) – List messages sent before a date and time.

  • before_message (str) – List messages sent before a message, by ID.

list_direct(parent_id: Optional[str] = None, person_id: Optional[str] = None, person_email: Optional[str] = None, **params) Generator[Message, None, None][source]

List all messages in a 1:1 (direct) room. Use the personId or personEmail query parameter to specify the room. Each message will include content attachments if present. The list sorts the messages in descending order by creation date.

Parameters
  • parent_id (str) – List messages with a parent, by ID.

  • person_id (str) – List messages in a 1:1 room, by person ID.

  • person_email (str) – List messages in a 1:1 room, by person email.

create(room_id: Optional[str] = None, parent_id: Optional[str] = None, to_person_id: Optional[str] = None, to_person_email: Optional[str] = None, text: Optional[str] = None, markdown: Optional[str] = None, files: Optional[List[str]] = None, attachments: Optional[List[Union[dict, MessageAttachment]]] = None) Message[source]

Post a plain text or rich text message, and optionally, a file attachment, to a room. The files parameter is an array, which accepts multiple values to allow for future expansion, but currently only one file may be included with the message. File previews are only rendered for attachments of 1MB or less.

Parameters
  • room_id (str) – The room ID of the message.

  • parent_id (str) – The parent message to reply to.

  • to_person_id (str) – The person ID of the recipient when sending a private 1:1 message.

  • to_person_email (str) – The email address of the recipient when sending a private 1:1 message.

  • text (str) – The message, in plain text. If markdown is specified this parameter may be optionally used to provide alternate text for UI clients that do not support rich text. The maximum message length is 7439 bytes.

  • markdown (str) – The message, in Markdown format. The maximum message length is 7439 bytes.

  • files (List[str]) – The public URL to a binary file or a path to a local file to be posted into the room. Only one file is allowed per message. Uploaded files are automatically converted into a format that all Webex clients can render. For the supported media types and the behavior of uploads, see the Message Attachments Guide.

  • attachments (List[Attachment]) – Content attachments to attach to the message. Only one card per message is supported. See the Cards Guide for more information.

Return type

Message

edit(message: Message) Message[source]

Update a message you have posted not more than 10 times. Specify the messageId of the message you want to edit. Edits of messages containing files or attachments are not currently supported. If a user attempts to edit a message containing files or attachments a 400 Bad Request will be returned by the API with a message stating that the feature is currently unsupported. There is also a maximum number of times a user can edit a message. The maximum currently supported is 10 edits per message. If a user attempts to edit a message greater that the maximum times allowed the API will return 400 Bad Request with a message stating the edit limit has been reached. While only the roomId and text or markdown attributes are required in the request body, a common pattern for editing message is to first call GET /messages/{id} for the message you wish to edit and to then update the text or markdown attribute accordingly, passing the updated message object in the request body of the PUT /messages/{id} request.

Parameters

message

the updated message, id has to be set in the message attributes supported for update:

  • room_id: str: The room ID of the message.

  • text: str: The message, in plain text. If markdown is specified this parameter may be optionally used to provide alternate text for UI clients that do not support rich text. The maximum message length is 7439 bytes.

  • markdown: str: The message, in Markdown format. If this attribute is set ensure that the request does NOT contain an html attribute.

details(message_id: str) Message[source]

Show details for a message, by message ID. Specify the message ID in the messageId parameter in the URI.

Parameters

message_id (str) – The unique identifier for the message.

delete(message_id: str)[source]

Delete a message, by message ID. Specify the message ID in the messageId parameter in the URI.

Parameters

message_id (str) – The unique identifier for the message.

base = 'messages'
session: RestSession

REST session