edge_st_sdk.aws package

Submodules

edge_st_sdk.aws.aws_client module

aws_client

The aws_client module represents a client capable of connecting to the Amazon AWS IoT cloud and performing edge operations through the Greengrass SDK.

class edge_st_sdk.aws.aws_client.AWSClient(client_name, device_certificate_path, device_private_key_path, group_ca_path, core_info)[source]

Bases: edge_st_sdk.edge_client.EdgeClient

Class responsible for handling an Amazon AWS client used for plain MQTT communication with AWS IoT.

__init__(client_name, device_certificate_path, device_private_key_path, group_ca_path, core_info)[source]

Constructor.

AWSClient has to be instantiated through a call to the edge_st_sdk.aws.aws_greengrass.AWSGreengrass.get_client() method.

Parameters
  • client_name (str) – Name of the client, as it is on the cloud.

  • device_certificate_path (str) – Relative path of the device’s certificate stored on the core device.

  • device_private_key_path (str) – Relative path of the device’s private key stored on the core device.

  • group_ca_path (str) – Relative path of the certification authority’s certificate stored on the core device.

  • core_info (list) – Information related to the core of the group to which the client belongs.

Raises

EdgeSTInvalidOperationException – is raised if the discovery of the core has not been completed yet, i.e. if the AWSClient has not been instantiated through a call to the edge_st_sdk.aws.aws_greengrass.AWSGreengrass.get_client() method.

add_listener(listener)[source]

Add a listener.

Parameters

listener (edge_st_sdk.edge_client.EdgeClientListener) – Listener to be added.

connect()[source]

Connect to the core.

Returns

True if the connection was successful, False otherwise.

Return type

bool

delete_shadow_state(callback, timeout_s)[source]

Delete the state of the shadow client.

Delete the device shadow from the cloud by publishing an empty JSON document to the corresponding shadow topics.

Parameters
  • callback – Function to be called when the response for a shadow request comes back.

  • timeout_s (int) – Timeout in seconds to perform the request.

disconnect()[source]

Disconnect from the core.

get_name()[source]

Get the client name.

Returns

The client name, i.e. the name of the client.

Return type

str

get_shadow_state(callback, timeout_s)[source]

Get the state of the shadow client.

Retrieve the device shadow JSON document from the cloud by publishing an empty JSON document to the corresponding shadow topics.

Parameters
  • callback – Function to be called when the response for a shadow request comes back.

  • timeout_s (int) – Timeout in seconds to perform the request.

publish(topic, payload, qos)[source]

Publish a new message to the desired topic with the given quality of service.

Parameters
  • topic (str) – Topic name to publish to.

  • payload (str) – Payload to publish (JSON formatted string).

  • qos (int) – Quality of Service. Could be “0” or “1”.

remove_listener(listener)[source]

Remove a listener.

Parameters

listener (edge_st_sdk.edge_client.EdgeClientListener) – Listener to be removed.

subscribe(topic, qos, callback)[source]

Subscribe to the desired topic with the given quality of service and register a callback to handle the published messages.

Parameters
  • topic (str) – Topic name to publish to.

  • qos (int) – Quality of Service. Could be “0” or “1”.

  • callback – Function to be called when a new message for the subscribed topic comes in.

unsubscribe(topic)[source]

Unsubscribe to the desired topic.

Parameters

topic (str) – Topic name to unsubscribe to.

update_shadow_state(payload, callback, timeout_s)[source]

Update the state of the shadow client.

Update the device shadow JSON document string on the cloud by publishing the provided JSON document to the corresponding shadow topics.

Parameters
  • payload (json) – JSON document string used to update the shadow JSON document on the cloud.

  • callback – Function to be called when the response for a shadow request comes back.

  • timeout_s (int) – Timeout in seconds to perform the request.

edge_st_sdk.aws.aws_greengrass module

aws_greengrass

The aws_greengrass module is responsible for managing the discovery process of AWS devices and allocating the needed resources.

class edge_st_sdk.aws.aws_greengrass.AWSGreengrass(endpoint, root_ca_path)[source]

Bases: object

MAX_DISCOVERY_ATTEMPTS = 3

Maximum number of attempts when trying to discover the core.

__init__(endpoint, root_ca_path)[source]

Constructor.

Initializing AWS Discovery.

Parameters
  • endpoint (str) – AWS endpoint.

  • root_ca_path (str) – Path to the root Certification Authority file.

add_listener(listener)[source]

Add a listener.

Parameters

listener (edge_st_sdk.aws.aws_greengrass.AWSGreengrassListener) – Listener to be added.

classmethod discovery_completed()[source]

Checking whether the discovery has completed.

Returns

True if the discovery process has completed, False otherwise.

Return type

bool

get_client(client_id, device_certificate_path, device_private_key_path)[source]

Getting an Amazon AWS client.

Parameters
  • client_id (str) – Name of the client, as it is on the cloud.

  • device_certificate_path (str) – Relative path of a device’s certificate stored on the core device.

  • device_private_key_path (str) – Relative path of a device’s private key stored on the core device.

Returns

Amazon AWS client.

Return type

edge_st_sdk.aws.aws_client.AWSClient

Raises
get_endpoint()[source]

Getting the AWS endpoint.

remove_listener(listener)[source]

Remove a listener.

Parameters

listener (edge_st_sdk.aws.aws_greengrass.AWSGreengrassListener) – Listener to be removed.

class edge_st_sdk.aws.aws_greengrass.AWSGreengrassListener[source]

Bases: object

Interface used by the edge_st_sdk.aws.aws_greengrass.AWSGreengrass class to notify changes of an AWS Greengrass service’s status.

abstract on_status_change(aws_greengrass, new_status, old_status)[source]

To be called whenever the AWS Greengrass service changes its status.

Parameters
Raises

NotImplementedError – if the method has not been implemented.

class edge_st_sdk.aws.aws_greengrass.AWSGreengrassStatus[source]

Bases: enum.Enum

Status of the AWS Greengrass service.

CORE_DISCOVERED = 'CORE_DISCOVERED'

Core discovered.

DISCOVERING_CORE = 'DISCOVERING_CORE'

Discovering the Core.

IDLE = 'IDLE'

Waiting for a connection and sending advertising data.

INIT = 'INIT'

Dummy initial status.

Module contents