pymod package

Submodules

pymod.ams module

class pymod.ams.AmsHttpRequests(endpoint, authn_port, token='', cert='', key='')[source]

Bases: object

Class encapsulates methods used by ArgoMessagingService.

Each method represent HTTP request made to AMS with the help of requests library. service error handling is implemented according to HTTP status codes returned by service and the balancer.

__init__(endpoint, authn_port, token='', cert='', key='')[source]

x.__init__(…) initializes x; see help(type(x)) for signature

assign_token(token, cert, key)[source]

Assign a token to the ams object

Args:
token(str): a valid ams token cert(str): a path to a valid certificate file key(str): a path to the associated key file for the provided certificate
auth_via_cert(cert, key, **reqkwargs)[source]

Retrieve an ams token based on the provided certificate

Args:
cert(str): a path to a valid certificate file key(str): a path to the associated key file for the provided certificate
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
do_delete(url, route_name, retry=0, retrysleep=60, retrybackoff=None, **reqkwargs)[source]

Delete method that is used to make the appropriate request.

Used for (topics, subscriptions).

Args:
url: str. The final messaging service endpoint route_name: str. The name of the route to follow selected from the route list reqkwargs: keyword argument that will be passed to underlying python-requests library call.
do_get(url, route_name, **reqkwargs)[source]

Method supports all the GET requests.

Used for (topics, subscriptions, users, messages).

Args:

url: str. The final messaging service endpoint route_name: str. The name of the route to follow selected from the route list reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
do_post(url, body, route_name, retry=0, retrysleep=60, retrybackoff=None, **reqkwargs)[source]

Method supports all the POST requests.

Used for (topics, subscriptions, users, messages).

Args:

url: str. The final messaging service endpoint body: dict. Body the post data to send based on the PUT request.

The post data is always in json format.
route_name: str. The name of the route to follow selected from
the route list
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
do_put(url, body, route_name, **reqkwargs)[source]

Method supports all the PUT requests.

Used for (topics, subscriptions, messages).

Args:

url: str. The final messaging service endpoint body: dict. Body the post data to send based on the PUT request.

The post data is always in json format.
route_name: str. The name of the route to follow selected from
the route list
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
class pymod.ams.ArgoMessagingService(endpoint, token='', project='', cert='', key='', authn_port=8443)[source]

Bases: pymod.ams.AmsHttpRequests

Class is entry point for client code.

Class abstract Argo Messaging Service by covering all available HTTP API calls that are wrapped in series of methods.

__init__(endpoint, token='', project='', cert='', key='', authn_port=8443)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

ack_sub(sub, ids, **reqkwargs)[source]

Acknownledgment of received messages

Messages retrieved from a pull subscription can be acknowledged by sending message with an array of ackIDs. The service will retrieve the ackID corresponding to the highest message offset and will consider that message and all previous messages as acknowledged by the consumer.

Args:
sub: str. The subscription name. ids: list(str). A list of ids of the messages to acknowledge. reqkwargs: keyword argument that will be passed to underlying python-requests library call.
add_project_member(username, project=None, roles=None, **reqkwargs)[source]

Assigns an existing user to the provided project with a POST request

Parameters:project ((str)) – the name of the project.If no

project is supplied, the declared global project will be used instead :param (str) username: the name of user :param (str[]) roles: project roles for the user :param reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
Returns:(AmsUser) the assigned user object
create_project(name, description, **reqkwargs)[source]

Create a new project using the provided name and description with a POST request

Parameters:
  • name – (str) the name of the project
  • description – (str) the description of the project
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
create_project_member(username, project=None, roles=None, email=None, **reqkwargs)[source]

This function creates a new user with a POST request under the given project

Parameters:project ((str)) – the name of the project.If no

project is supplied, the declared global project will be used instead :param (str) username: the name of the user :param (str) email: the email of the user :param (str[]) roles: project roles for the user

Returns:(AmsUser) the assigned user object
create_sub(sub, topic, ackdeadline=10, push_endpoint=None, retry_policy_type='linear', retry_policy_period=300, retobj=False, **reqkwargs)[source]

This function creates a new subscription in a project with a PUT request

Args:

sub: str. The subscription name. topic: str. The topic name. ackdeadline: int. It is a custom “ack” deadline (in seconds) in

the subscription. If your code doesn’t acknowledge the message in this time, the message is sent again. If you don’t specify the deadline, the default is 10 seconds.
push_endpoint: URL of remote endpoint that should receive
messages in push subscription mode

retry_policy_type: retry_policy_period: retobj: Controls whether method should return AmsSubscription object reqkwargs: keyword argument that will be passed to underlying python-requests library call.

create_topic(topic, retobj=False, **reqkwargs)[source]

This function creates a topic in a project

Args:

topic: str. The topic name. retobj: Controls whether method should return AmsTopic object reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
create_user(user, **reqkwargs)[source]

This function creates a new user with a POST request

Args:
user: AmsUser. The user to be created. reqkwargs: keyword argument that will be passed to underlying python-requests library call.
Return:
object (AmsUser)
delete_project(name, **reqkwargs)[source]

Delete a project using the provided name with a DELETE request

Parameters:
  • name – (str) the name of the project
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
delete_sub(sub, **reqkwargs)[source]

This function deletes a selected subscription in a project

Args:

sub: str. The subscription name. reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
delete_topic(topic, **reqkwargs)[source]

This function deletes a topic in a project

Args:

topic: str. The topic name. reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
delete_user(name, **reqkwargs)[source]

Deletes the respective user using the provided username with a DELETE request

Parameters:
  • name – (str) the username of the user to be retrieved
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
get_project(name, **reqkwargs)[source]

Retrieve a project using the provided name with a GET request

Parameters:
  • name – (str) the name of the project
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
get_project_member(username, project=None, **reqkwargs)[source]

Retrieves the respective project member using the provided username with a GET request

Parameters:
  • username – (str) the username of the user to be retrieved
  • project – (str) the name of the project the user belongs to.If no

project is supplied, the declared global project will be used instead :param reqkwargs: keyword arguments that will be passed to underlying

python-requests library call.
Returns:(AmsUser) the ams user
get_pullopt(key)[source]

Function for getting pull options

Args:
key: str. The name of the pull option (ex. maxMessages,
returnImmediately). Messaging specific names are allowed.
Returns:
str. The value of the pull option
get_sub(sub, retobj=False, **reqkwargs)[source]

Get the details of a subscription.

Args:

sub: str. The subscription name. retobj: Controls whether method should return AmsSubscription object reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
get_topic(topic, retobj=False, **reqkwargs)[source]

Get the details of a selected topic.

Args:

topic: str. Topic name. retobj: Controls whether method should return AmsTopic object reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
get_user(name, **reqkwargs)[source]

Retrieves the respective user using the provided username with a GET request

Parameters:
  • name – (str) the username of the user to be retrieved
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
Returns:

(AmsUser) the ams user

get_user_by_token(token, **reqkwargs)[source]

Retrieves the respective user using the provided token with a GET request

Parameters:
  • token – (str) the token of the user to be retrieved
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
Returns:

(AmsUser) the ams user

get_user_by_uuid(uuid, **reqkwargs)[source]

Retrieves the respective user using the provided uuid with a GET request

Parameters:
  • uuid – (str) the uuid of the user to be retrieved
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
Returns:

(AmsUser) the ams user

get_user_profile(**reqkwargs)[source]

Retrieves the respective user using the provided token in the ams object with a GET request :param reqkwargs: keyword arguments that will be passed to underlying

python-requests library call.
Returns:(AmsUser) the ams user
getacl_sub(sub, **reqkwargs)[source]

Get access control lists for subscription

Args:
sub (str): The subscription name.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
getacl_topic(topic, **reqkwargs)[source]

Get access control lists for topic

Args:
topic (str): The topic name.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
getoffsets_sub(sub, offset='all', **reqkwargs)[source]

Retrieve the current positions of min,max and current offsets.

Args:
sub (str): The subscription name. offset(str): The name of the offset.If not specified, it will return all three of them as a dict.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
has_sub(sub, **reqkwargs)[source]

Inspect if subscription already exists or not

Args:
sub: str. The subscription name.
has_topic(topic, **reqkwargs)[source]

Inspect if topic already exists or not

Args:
topic: str. Topic name
iter_subs(topic=None, **reqkwargs)[source]

Iterate over AmsSubscription objects

Args:
topic: Iterate over subscriptions only associated to this topic name
iter_topics(**reqkwargs)[source]

Iterate over AmsTopic objects

list_subs(**reqkwargs)[source]

Lists all subscriptions in a project with a GET request.

Args:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
list_topics(**reqkwargs)[source]

List the topics of a selected project

Args:
reqkwargs: keyword argument that will be passed to underlying python-requests library call
list_users(details=True, page_size=0, next_page_token='', **reqkwargs)[source]

Retrieves the respective user using the provided token in the ams object with a GET request :param next_page_token: (str) next page token in case of paginated retrieval :param page_size: (int) size of each page :param details: (bool) whether to include project details per user :param reqkwargs: keyword arguments that will be passed to underlying

python-requests library call.
Returns:(AmsUserPage) a page containing AmsUser objects and pagination details
metrics(**reqkwargs)[source]

Retrieves the operational metrics of the service

Parameters:reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
modifyacl_sub(sub, users, **reqkwargs)[source]

Modify access control lists for subscription

Args:

sub (str): The subscription name. users (list): List of users that will have access to subscription.

Empty list of users will reset access control list.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
modifyacl_topic(topic, users, **reqkwargs)[source]

Modify access control lists for topic

Args:

topic (str): The topic name. users (list): List of users that will have access to topic.

Empty list of users will reset access control list.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
modifyoffset_sub(sub, move_to, **reqkwargs)[source]

Modify the position of the current offset.

Args:
sub (str): The subscription name. move_to(int): Position to move the offset.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
publish(topic, msg, retry=0, retrysleep=60, retrybackoff=None, **reqkwargs)[source]

Publish a message or list of messages to a selected topic.

If enabled (retry > 0), multiple topic publishes will be tried in case of problems/glitches with the AMS service. retry* options are eventually passed to _retry_make_request()

Args:

topic (str): Topic name. msg (list): A list with one or more messages to send.

Each message is represented as AmsMessage object or python dictionary with at least data or one attribute key defined.
Kwargs:
retry: int. Number of request retries before giving up. Default
is 0 meaning no further request retry will be made after first unsuccesfull request.
retrysleep: int. Static number of seconds to sleep before next
request attempt
retrybackoff: int. Backoff factor to apply between each request
attempts
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
Return:
dict: Dictionary with messageIds of published messages
pull_sub(sub, num=1, return_immediately=False, retry=0, retrysleep=60, retrybackoff=None, **reqkwargs)[source]

This function consumes messages from a subscription in a project with a POST request.

If enabled (retry > 0), multiple subscription pulls will be tried in case of problems/glitches with the AMS service. retry* options are eventually passed to _retry_make_request()

Args:

sub: str. The subscription name. num: int. The number of messages to pull. reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
pullack_sub(sub, num=1, return_immediately=False, retry=0, retrysleep=60, retrybackoff=None, **reqkwargs)[source]

Pull messages from subscription and acknownledge them in one call.

If enabled (retry > 0), multiple subscription pulls will be tried in case of problems/glitches with the AMS service. retry* options are eventually passed to _retry_make_request().

If succesfull subscription pull immediately follows with failed acknownledgment (e.g. network hiccup just before acknowledgement of received messages), consume cycle will reset and start from beginning with new subscription pull. This ensures that ack deadline time window is moved to new start period, that is the time when the second pull was initiated.

Args:

sub: str. The subscription name. num: int. The number of messages to pull. reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
pushconfig_sub(sub, push_endpoint=None, retry_policy_type='linear', retry_policy_period=300, **reqkwargs)[source]

Modify push configuration of given subscription

Args:
sub: shortname of subscription push_endpoint: URL of remote endpoint that should receive messages in push subscription mode retry_policy_type: retry_policy_period: reqkwargs: keyword argument that will be passed to underlying python-requests library call.
refresh_user_token(name, **reqkwargs)[source]

Refresh the token for the respective user using the provided username with a POST request

param name:(str) the username of the user to be retrieved
param reqkwargs:
 keyword arguments that will be passed to underlying python-requests library call.
Returns:(AmsUser) the ams user
remove_project_member(username, project, **reqkwargs)[source]

Removes an existing user from the provided project with a POST request

Parameters:
  • username – (str) the name of user
  • project – (Str) the name of the project
  • reqkwargs – keyword argument that will be passed to underlying python-requests library call.
set_pullopt(key, value)[source]

Function for setting pull options

Args:
key: str. The name of the pull option (ex. maxMessages, returnImmediately). Messaging specific
names are allowed.
value: str or int. The name of the pull option (ex. maxMessages,
returnImmediately). Messaging specific names are allowed.
status(**reqkwargs)[source]

Retrieves the status of the service

Parameters:reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
time_to_offset_sub(sub, timestamp, **reqkwargs)[source]

Retrieve the closest(greater than) available offset to the given timestamp.

Args:
sub (str): The subscription name. timestamp(datetime.datetime): The timestamp of the offset we are looking for.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
topic(topic, **reqkwargs)[source]

Function create a topic in a project.

It’s wrapper around few methods defined in client class. Method will ensure that AmsTopic object is returned either by fetching existing one or creating a new one in case it doesn’t exist.

Args:
topic (str): The topic name
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
Return:
object (AmsTopic)
update_project(name, description='', updated_name='', **reqkwargs)[source]

Create a new project using the provided name and description with a POST request

Parameters:
  • name – (str) the name of the project
  • description – (str) the description of the project
  • updated_name – (str) updated name
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
update_user(name, first_name='', last_name='', description='', organization='', username='', email='', service_roles=None, projects=None, **reqkwargs)[source]

Update the respective user using the provided username with a PUT request

Parameters:
  • last_name – (str) the last name of the user
  • first_name – (str) the first name of the user
  • description – (str) user description
  • organization – (str) user organisation
  • username – (str) new username
  • email – (str) the email the user
  • service_roles – (str[]) new service roles
  • projects – (AmsUserProject[]) new projects and roles
  • name – (str) the username of the user to be updated
  • reqkwargs – keyword arguments that will be passed to underlying python-requests library call.
Returns:

(AmsUser) the ams user

usage_report(projects=None, start_date=None, end_date=None, **reqkwargs)[source]

Retrieves va report metrics for the given projects and the given time period alongside the service’s operational metrics. The api call will retrieve all projects that the requesting user is a project admin for. :param projects: (str[]) filter based on the given projects :param start_date: (datetime.datetime time period starting date :param end_date: (datetime.datetime) time period end date :param reqkwargs: keyword arguments that will be passed to underlying

python-requests library call.
va_metrics(projects=None, start_date=None, end_date=None, **reqkwargs)[source]

Retrieves va report metrics for the given projects and the given time period :param projects: (str[]) filter based on the given projects :param start_date: (datetime.datetime time period starting date :param end_date: (datetime.datetime) time period end date :param reqkwargs: keyword arguments that will be passed to underlying

python-requests library call.
version(**reqkwargs)[source]

Retrieves the version information about the service

Parameters:reqkwargs – keyword arguments that will be passed to underlying python-requests library call.

pymod.amsexceptions module

exception pymod.amsexceptions.AmsBalancerException(json, request)[source]

Bases: pymod.amsexceptions.AmsServiceException

Exception for load balancer Argo Messaging Service errors

__init__(json, request)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

exception pymod.amsexceptions.AmsConnectionException(exp, request)[source]

Bases: pymod.amsexceptions.AmsException

Exception for connection related problems catched from requests library

__init__(exp, request)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

exception pymod.amsexceptions.AmsException(*args, **kwargs)[source]

Bases: exceptions.Exception

Base exception class for all Argo Messaging service related errors

__init__(*args, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

exception pymod.amsexceptions.AmsMessageException(msg)[source]

Bases: pymod.amsexceptions.AmsException

Exception that indicate problems with constructing message

__init__(msg)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

exception pymod.amsexceptions.AmsServiceException(json, request)[source]

Bases: pymod.amsexceptions.AmsException

Exception for Argo Messaging Service API errors

__init__(json, request)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

exception pymod.amsexceptions.AmsTimeoutException(json, request)[source]

Bases: pymod.amsexceptions.AmsServiceException

Exception for timeouts errors

Timeouts can be generated by the Argo Messaging Service if message was not acknownledged in desired time frame (ackDeadlineSeconds). Also, 408 timeouts can come from load balancer for partial requests that were not completed in required time frame.

__init__(json, request)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

pymod.amsmsg module

class pymod.amsmsg.AmsMessage(b64enc=True, attributes='', data=None, messageId='', publishTime='')[source]

Bases: _abcoll.Callable

Abstraction of AMS Message

AMS Message is constituted from mandatory data field and arbitrary number of attributes. Data is Base64 encoded prior dispatching message to AMS service and Base64 decoded when it is being pulled from service.

__init__(b64enc=True, attributes='', data=None, messageId='', publishTime='')[source]

x.__init__(…) initializes x; see help(type(x)) for signature

dict()[source]

Construct python dict from message

get_attr()[source]

Fetch all attributes of the message

get_data()[source]

Fetch the data of the message and Base64 decode it

get_msgid()[source]

Fetch the message id of the message

get_publishtime()[source]

Fetch the publish time of the message set by the AMS service

json()[source]

Return JSON interpretation of the message

set_attr(key, value)[source]

Set attributes of message

Args:
key (str): Key of the attribute value (str): Value of the attribute
set_data(data, b64enc=True)[source]

Set data of message

Default behaviour is to Base64 encode data prior sending it by the publisher. Method is also used internally when pull from subscription is being made by subscriber and in that case, data is already Base64 encoded

Args:
data (str): Data of the message
Kwargs:
b64enc (bool): Control whether data should be Base64 encoded

pymod.amssubscription module

class pymod.amssubscription.AmsSubscription(fullname, topic, pushconfig, ackdeadline, init)[source]

Bases: object

Abstraction of AMS subscription

Subscription represents stream of messages that can be pulled from AMS service or pushed to some receiver. Supported methods are wrappers around methods defined in client class with preconfigured subscription name.

__init__(fullname, topic, pushconfig, ackdeadline, init)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

ack(ids, retry=0, retrysleep=60, retrybackoff=None, **reqkwargs)[source]

Acknowledge receive of messages

Kwargs:

ids (list): A list of ackIds of the messages to acknowledge. retry: int. Number of request retries before giving up. Default

is 0 meaning no further request retry will be made after first unsuccesfull request.
retrysleep: int. Static number of seconds to sleep before next
request attempt
retrybackoff: int. Backoff factor to apply between each request
attempts
acl(users=None, **reqkwargs)[source]

Set or get ACLs assigned to subscription

Kwargs:
users (list): If list of users is specified, give those user
access to subscription. Empty list will reset access permission.
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
delete()[source]

Delete subscription

offsets(offset='all', move_to=0, **reqkwargs)[source]

Retrieve the positions of min, max and current offsets or move current offset to new one.

Args:
offset (str): The name of the offset. If not specified, it will
return all three of them as a dict. Values that can be specified are ‘max’, ‘min’, ‘current’ and ‘all’.

move_to (int): New position for current offset.

Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
Return:
dict: A dictionary containing all 3 offsets. If move_to
is specified, current offset will be moved and updated.

int: The value of the specified offset.

pull(num=1, retry=0, retrysleep=60, retrybackoff=None, return_immediately=False, **reqkwargs)[source]

Pull messages from subscription

Kwargs:

num (int): Number of messages to pull retry: int. Number of request retries before giving up. Default

is 0 meaning no further request retry will be made after first unsuccesfull request.
retrysleep: int. Static number of seconds to sleep before next
request attempt
retrybackoff: int. Backoff factor to apply between each request
attempts
return_immediately (boolean): If True and if stream of messages is empty,
subscriber call will not block and wait for messages
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
Return:
[(ackId, AmsMessage)]: List of tuples with ackId and AmsMessage instance
pullack(num=1, retry=0, retrysleep=60, retrybackoff=None, return_immediately=False, **reqkwargs)[source]

Pull messages from subscription and acknownledge them in one call.

If succesfull subscription pull immediately follows with failed acknownledgment (e.g. network hiccup just before acknowledgement of received messages), consume cycle will reset and start from begginning with new subscription pull.

Kwargs:

num (int): Number of messages to pull retry: int. Number of request retries before giving up. Default

is 0 meaning no further request retry will be made after first unsuccesfull request.
retrysleep: int. Static number of seconds to sleep before next
request attempt
retrybackoff: int. Backoff factor to apply between each request
attempts
return_immediately (boolean): If True and if stream of messages is empty,
subscriber call will not block and wait for messages
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
Return:
[AmsMessage1, AmsMessage2]: List of AmsMessage instances
pushconfig(push_endpoint=None, retry_policy_type='linear', retry_policy_period=300, **reqkwargs)[source]

Configure Push mode parameters of subscription. When push_endpoint is defined, subscription will automatically start to send messages to it.

Kwargs:

push_endpoint (str): URL of remote endpoint that will receive messages retry_policy_type (str): retry_policy_period (int): reqkwargs: keyword argument that will be passed to underlying

python-requests library call.
time_to_offset(timestamp, **reqkwargs)[source]

Retrieve the closest(greater than) available offset to the given timestamp.

Args:
timestamp(datetime.datetime): The timestamp of the offset we are looking for.
Kwargs:
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.

pymod.amstopic module

class pymod.amstopic.AmsTopic(fullname, init)[source]

Bases: object

Abstraction of AMS Topic

Topic represents named bucket on AMS service that can hold messages. Supported methods are wrappers around the methods defined in client class with preconfigured topic name.

__init__(fullname, init)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

acl(users=None, **reqkwargs)[source]

Set or get ACLs assigned to topic

Kwargs:
users (list): If list of users is specified, give those user
access to topic. Empty list will reset access permission.
reqkwargs: keyword argument that will be passed to underlying
python-requests library call.
delete()[source]

Delete topic

Return:
True: successfull topic deletion
iter_subs()[source]

Generator method that can be used to iterate over subscriptions associated with the topic

publish(msg, retry=0, retrysleep=60, retrybackoff=None, **reqkwargs)[source]

Publish message to topic

Args:
msg (list, dict): One or list of dictionaries representing AMS
Message
Kwargs:
retry: int. Number of request retries before giving up. Default
is 0 meaning no further request retry will be made after first unsuccesfull request.
retrysleep: int. Static number of seconds to sleep before next
request attempt
retrybackoff: int. Backoff factor to apply between each request
attempts
reqkwargs: Keyword argument that will be passed to underlying
python-requests library call.
Returns:
dict: Dictionary with messageIds of published messages
subscription(sub, ackdeadline=10, **reqkwargs)[source]

Create a subscription for the topic.

It’s wrapper around few methods defined in client class. Method will ensure that AmsSubscription object is returned either by fetching existing one or creating a new one in case it doesn’t exist.

Args:
sub (str): Name of the subscription
Kwargs:
ackdeadline (int): Time window in which the AMS service expects
acknowledgement received for pulled messages
reqkwargs: Keyword arguments that will be passed to underlying
python-requests library call.
Return:
object (AmsSubscription)

Module contents