Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add silent message update support #287

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api_client_generation/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ code_gen_dir=`pwd`
project_root=$code_gen_dir/..
echo $code_gen_dir

commit_hash=136b530512eea112de73591906051871d034750a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we update this commit hash, we might want to run the sh script to update the generated code. See here https://github.com/finos/symphony-bdk-python/blob/main/docsrc/markdown/tech/generated_api.md

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And include the new generated files in the PR of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, i am doing it now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit_hash=46abc03ad7225ebc32439c06920019c9d0fb0814
api_spec_base_url=https://raw.githubusercontent.com/symphonyoss/symphony-api-spec/${commit_hash}
echo $api_spec_base_url

Expand Down
10 changes: 7 additions & 3 deletions symphony/bdk/core/service/message/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ async def search_messages_one_page(skip, limit):

@retry
async def update_message(self, stream_id: str, message_id: str, message: Union[str, Message], data=None,
version: str = "") -> V4Message:
version: str = "", silent=True) -> V4Message:
"""Update an existing message. The existing message must be a valid social message, that has not been deleted.
See: `Update Message <https://developers.symphony.com/restapi/reference/update-message-v4>`_

Expand All @@ -476,12 +476,15 @@ async def update_message(self, stream_id: str, message_id: str, message: Union[s
If it is a :py:class:`Message` instance, other parameters will be ignored.
If it is a string, ``<messageML>`` tags can be omitted.
:param data: an object (e.g. dict) that will be serialized into JSON using ``json.dumps``.
:param silent: a bool flag that will determine if the updated message is going to be marked as read (when true,
which is default value) or unread (when false).
:param version: Optional message version in the format "major.minor".
If empty, defaults to the latest supported version.

:return: a V4Message object containing the details of the updated message.
"""
message_object = message if isinstance(message, Message) else Message(content=message, data=data, version=version)
message_object = message if isinstance(message, Message) else Message(content=message, data=data, silent=silent,
version=version)

params = {
"sid": stream_id,
Expand All @@ -490,7 +493,8 @@ async def update_message(self, stream_id: str, message_id: str, message: Union[s
"key_manager_token": await self._auth_session.key_manager_token,
"message": message_object.content,
"data": message_object.data,
"version": message_object.version
"version": message_object.version,
"silent": str(message_object.silent)
}
return await self._messages_api.v4_stream_sid_message_mid_update_post(**params)

Expand Down
15 changes: 13 additions & 2 deletions symphony/bdk/core/service/message/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class Message:
`Create Message <https://developers.symphony.com/restapi/reference/create-message-v4>`_.
"""

def __init__(self, content: str, data=None,
def __init__(self, content: str, data=None, silent=True,
attachments: List[Union[IO, Tuple[IO, IO]]] = None, version: str = ""):
"""Builds a message.

:param content: the MessageML content to be sent. This is mandatory
If there is no <messageML> tags, they will be added to the content.
:param data: an object (e.g. dict) that will be serialized into JSON using ``json.dumps``
:param data: an object (e.g. dict) that will be serialized into JSON using ``json.dumps``.
:param silent: the bool flag determine if the updated message will be marked as read (when it
is true and it s the default value) or unread (when it is false)
:param attachments: list of attachments or list of (attachment, previews).
These must be opened files either in binary or text mode.
Previews are optional but if present, all attachments must have a preview.
Expand All @@ -32,6 +34,7 @@ def __init__(self, content: str, data=None,
self._content = self._get_content(content)
self._data = "" if data is None else json.dumps(data)
self._version = version
self._silent = silent
self._attachments, self._previews = self._get_attachments_and_previews(attachments)

@property
Expand All @@ -58,6 +61,14 @@ def version(self) -> str:
"""
return self._version

@property
def silent(self) -> str:
"""Message silent flag

:return: the message silent value
"""
return self._silent

@property
def attachments(self) -> List[IO]:
"""List of attachments
Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/attachments_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/audit_trail_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/datafeed_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/messages_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/share_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/signals_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/system_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
2 changes: 1 addition & 1 deletion symphony/bdk/gen/agent_api/util_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This document refers to Symphony API calls to send and receive messages and content. They need the on-premise Agent installed to perform decryption/encryption of content. - sessionToken and keyManagerToken can be obtained by calling the authenticationAPI on the symphony back end and the key manager respectively. Refer to the methods described in authenticatorAPI.yaml. - A new authorizationToken has been introduced in the authenticationAPI response payload. It can be used to replace the sessionToken in any of the API calls and can be passed as \"Authorization\" header. - Actions are defined to be atomic, ie will succeed in their entirety or fail and have changed nothing. - If it returns a 40X status then it will have sent no message to any stream even if a request to some subset of the requested streams would have succeeded. - If this contract cannot be met for any reason then this is an error and the response code will be 50X. - MessageML is a markup language for messages. See reference here: https://rest-api.symphony.com/docs/messagemlv2 - **Real Time Events**: The following events are returned when reading from a real time messages and events stream (\"datafeed\"). These events will be returned for datafeeds created with the v5 endpoints. To know more about the endpoints, refer to Create Messages/Events Stream and Read Messages/Events Stream. Unless otherwise specified, all events were added in 1.46. # noqa: E501

The version of the OpenAPI document: 22.5.1-SNAPSHOT
The version of the OpenAPI document: 22.5.1
Generated by: https://openapi-generator.tech
"""

Expand Down
Loading