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.EdgeClientClass 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
-
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.
-
get_name()[source]¶ Get the client name.
- Returns
The client name, i.e. the name of the client.
- Return type
-
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.
-
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.
-
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.
-
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
-
get_client(client_id, device_certificate_path, device_private_key_path)[source]¶ Getting an Amazon AWS client.
- Parameters
- Returns
Amazon AWS client.
- Return type
- Raises
EdgeSTInvalidOperationException – is raised if the discovery of the core fails.
EdgeSTInvalidDataException – is raised if a wrong configuration data is provided.
-
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:
objectInterface used by the
edge_st_sdk.aws.aws_greengrass.AWSGreengrassclass 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
aws_greengrass (
edge_st_sdk.aws.aws_greengrass.AWSGreengrass) – AWS Greengrass service that has changed its status.new_status (
edge_st_sdk.aws.aws_greengrass.AWSGreengrassStatus) – New status.old_status (
edge_st_sdk.aws.aws_greengrass.AWSGreengrassStatus) – Old status.
- Raises
NotImplementedError – if the method has not been implemented.
-
abstract
-
class
edge_st_sdk.aws.aws_greengrass.AWSGreengrassStatus[source]¶ Bases:
enum.EnumStatus 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.
-