SMN API¶
The Simple Message Notification Service Class¶
The SMN high-level interface is available through the smn
member of a Connection
object. The
smn
member will only be added if the
otcextensions.sdk.register_otc_extensions(conn)
method is called.
Subscription Operations¶
- class otcextensions.sdk.smn.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- create_subscription(topic, **attrs)
Create a new Subscription from attributes
- Parameters:
topic – Either the ID of a topic or a
Topic
instance.attrs (dict) – Keyword arguments which will be used to create a
Subscription
- Returns:
- delete_subscription(subscription, ignore_missing=True)
Delete a subscription
- Parameters:
subscription – Either the ID of a subscription or a :class: ~otcextensions.sdk.smn.v2.subscription.Subscription instance.
ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised if the subscription does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent subscription.
- Returns:
None
- subscriptions(topic=None, **query)
Return a generator of Subscriptions
- Parameters:
topic – Either the ID of a topic or a :class: ~otcextensions.sdk.smn.v2.topic.Topic instance.
query (dict) – Optional query parameters to be sent to limit the resources being returned.
- Returns:
A generator of subscription objects
- Return type:
SMS Operations¶
- class otcextensions.sdk.smn.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- send_sms(endpoint, message)
Send a transactional SMS message to a specified phone number, usually used for verification code or notification.
- Parameters:
endpoint – Phone number.
message – SMS message content.
- Returns:
Template Operations¶
- class otcextensions.sdk.smn.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- create_template(**attrs)
Create a new message template from attributes
- delete_template(template, ignore_missing=True)
Delete a message template
- Parameters:
template – message template ID or an instance of
Template
ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the template does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent template.
- Returns:
None
- templates(**query)
Return a generator of message templates
- Parameters:
query (dict) – Optional query parameters to be sent to limit the resources being returned.
- Returns:
A generator of template objects.
- Return type:
- get_template(template)
Get details a message templates
- update_template(template, **attrs)
Update a message template
- find_template(name_or_id, ignore_missing=False)
Find a single message template.
- Parameters:
name_or_id – The name or ID of a template.
ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the template does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent template.
- Returns:
One
Template
Topic Operations¶
- class otcextensions.sdk.smn.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- create_topic(**attrs)
Create a new topic from attributes
- delete_topic(topic, ignore_missing=True)
Delete a topic
- Parameters:
topic – topic urn or an instance of
Topic
ignore_missing (bool) – When set to
False
ResourceNotFound
will be raised when the topic does not exist. When set toTrue
, no exception will be set when attempting to delete a nonexistent topic.
- Returns:
None
- topics(**query)
Return a generator of SMN topics
- Parameters:
query (dict) – Optional query parameters to be sent to limit the resources being returned.
- Returns:
A generator of topic objects
- Return type:
- get_topic(topic)
Get details a SMN topic
Topic Attribute Operations¶
- class otcextensions.sdk.smn.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- topic_attributes(topic, **query)
Get SMN topic attributes
- Parameters:
topic – The value can be the ID of a topic or a
Topic
instance.query – Attribute query params.
- Returns:
One
TopicAttribute
- Raises:
ResourceNotFound
when no resource can be found.
- update_topic_attribute(topic, name='access_policy', **attrs)
Update SMN topic attributes
- Parameters:
topic – Either the ID of a topic or a
Topic
instance.name – Attribute Name.
attrs (dict) – The attributes to update on the topic represented by
TopicAttribute
- Returns:
request_id.
- Return type:
- Raises:
ResourceNotFound
when no resource can be found.
- delete_topic_attribute(topic, name=None)
Delete all attributes of a topic
- Parameters:
topic – Either the ID of a topic or a
Topic
instance.name – Attribute Name.
- Returns:
request_id.
- Return type:
- Raises:
ResourceNotFound
when no resource can be found.
Message Operations¶
- class otcextensions.sdk.smn.v2._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
- publish_message(topic, **attrs)
Publish messages in the text format or using message structure or using a message template to a topic.
- Parameters:
topic – Either the ID of a topic or a :class: ~otcextensions.sdk.smn.v2.topic.Topic instance.
attrs (dict) – Keyword arguments which will be used to Publish a Message.
- Returns: