awsiot.iotidentity

class awsiot.iotidentity.IotIdentityClient(mqtt_connection)

Bases: MqttServiceClient

An AWS IoT service that assists with provisioning a device and installing unique client certificates on it

AWS Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html

Parameters:

mqtt_connection (Connection) –

publish_create_certificate_from_csr(request, qos)

Creates a certificate from a certificate signing request (CSR). AWS IoT provides client certificates that are signed by the Amazon Root certificate authority (CA). The new certificate has a PENDING_ACTIVATION status. When you call RegisterThing to provision a thing with this certificate, the certificate status changes to ACTIVE or INACTIVE as described in the template.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
Returns:

A Future whose result will be None if the request is successfully published. The Future’s result will be an exception if the request cannot be published.

Return type:

Future

publish_create_keys_and_certificate(request, qos)

Creates new keys and a certificate. AWS IoT provides client certificates that are signed by the Amazon Root certificate authority (CA). The new certificate has a PENDING_ACTIVATION status. When you call RegisterThing to provision a thing with this certificate, the certificate status changes to ACTIVE or INACTIVE as described in the template.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
Returns:

A Future whose result will be None if the request is successfully published. The Future’s result will be an exception if the request cannot be published.

Return type:

Future

publish_register_thing(request, qos)

Provisions an AWS IoT thing using a pre-defined template.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
  • request (RegisterThingRequest) – RegisterThingRequest instance.

  • qos (int) – The Quality of Service guarantee of this message

Returns:

A Future whose result will be None if the request is successfully published. The Future’s result will be an exception if the request cannot be published.

Return type:

Future

subscribe_to_create_certificate_from_csr_accepted(request, qos, callback)

Subscribes to the accepted topic of the CreateCertificateFromCsr operation.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
Returns:

Tuple with two values. The first is a Future whose result will be the awscrt.mqtt.QoS granted by the server, or an exception if the subscription fails. The second value is a topic which may be passed to unsubscribe() to stop receiving messages. Note that messages may arrive before the subscription is acknowledged.

Return type:

Tuple[Future, str]

subscribe_to_create_certificate_from_csr_rejected(request, qos, callback)

Subscribes to the rejected topic of the CreateCertificateFromCsr operation.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
  • request (CreateCertificateFromCsrSubscriptionRequest) – CreateCertificateFromCsrSubscriptionRequest instance.

  • qos (int) – The Quality of Service guarantee of this message

  • callback (Callable[[ErrorResponse], None]) – Callback to invoke each time the event is received. The callback should take 1 argument of type ErrorResponse. The callback is not expected to return anything.

Returns:

Tuple with two values. The first is a Future whose result will be the awscrt.mqtt.QoS granted by the server, or an exception if the subscription fails. The second value is a topic which may be passed to unsubscribe() to stop receiving messages. Note that messages may arrive before the subscription is acknowledged.

Return type:

Tuple[Future, str]

subscribe_to_create_keys_and_certificate_accepted(request, qos, callback)

Subscribes to the accepted topic of the CreateKeysAndCertificate operation.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
Returns:

Tuple with two values. The first is a Future whose result will be the awscrt.mqtt.QoS granted by the server, or an exception if the subscription fails. The second value is a topic which may be passed to unsubscribe() to stop receiving messages. Note that messages may arrive before the subscription is acknowledged.

Return type:

Tuple[Future, str]

subscribe_to_create_keys_and_certificate_rejected(request, qos, callback)

Subscribes to the rejected topic of the CreateKeysAndCertificate operation.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
  • request (CreateKeysAndCertificateSubscriptionRequest) – CreateKeysAndCertificateSubscriptionRequest instance.

  • qos (int) – The Quality of Service guarantee of this message

  • callback (Callable[[ErrorResponse], None]) – Callback to invoke each time the event is received. The callback should take 1 argument of type ErrorResponse. The callback is not expected to return anything.

Returns:

Tuple with two values. The first is a Future whose result will be the awscrt.mqtt.QoS granted by the server, or an exception if the subscription fails. The second value is a topic which may be passed to unsubscribe() to stop receiving messages. Note that messages may arrive before the subscription is acknowledged.

Return type:

Tuple[Future, str]

subscribe_to_register_thing_accepted(request, qos, callback)

Subscribes to the accepted topic of the RegisterThing operation.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
  • request (RegisterThingSubscriptionRequest) – RegisterThingSubscriptionRequest instance.

  • qos (int) – The Quality of Service guarantee of this message

  • callback (Callable[[RegisterThingResponse], None]) – Callback to invoke each time the event is received. The callback should take 1 argument of type RegisterThingResponse. The callback is not expected to return anything.

Returns:

Tuple with two values. The first is a Future whose result will be the awscrt.mqtt.QoS granted by the server, or an exception if the subscription fails. The second value is a topic which may be passed to unsubscribe() to stop receiving messages. Note that messages may arrive before the subscription is acknowledged.

Return type:

Tuple[Future, str]

subscribe_to_register_thing_rejected(request, qos, callback)

Subscribes to the rejected topic of the RegisterThing operation.

API Docs: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api

Parameters:
  • request (RegisterThingSubscriptionRequest) – RegisterThingSubscriptionRequest instance.

  • qos (int) – The Quality of Service guarantee of this message

  • callback (Callable[[ErrorResponse], None]) – Callback to invoke each time the event is received. The callback should take 1 argument of type ErrorResponse. The callback is not expected to return anything.

Returns:

Tuple with two values. The first is a Future whose result will be the awscrt.mqtt.QoS granted by the server, or an exception if the subscription fails. The second value is a topic which may be passed to unsubscribe() to stop receiving messages. Note that messages may arrive before the subscription is acknowledged.

Return type:

Tuple[Future, str]

class awsiot.iotidentity.CreateCertificateFromCsrRequest(*args, **kwargs)

Bases: ModeledClass

Data needed to perform a CreateCertificateFromCsr operation.

All attributes are None by default, and may be set by keyword in the constructor.

Keyword Arguments:

certificate_signing_request (str) – The CSR, in PEM format.

certificate_signing_request

The CSR, in PEM format.

Type:

str

class awsiot.iotidentity.CreateCertificateFromCsrResponse(*args, **kwargs)

Bases: ModeledClass

Response payload to a CreateCertificateFromCsr request.

All attributes are None by default, and may be set by keyword in the constructor.

Keyword Arguments:
  • certificate_id (str) – The ID of the certificate.

  • certificate_ownership_token (str) – The token to prove ownership of the certificate during provisioning.

  • certificate_pem (str) – The certificate data, in PEM format.

certificate_id

The ID of the certificate.

Type:

str

certificate_ownership_token

The token to prove ownership of the certificate during provisioning.

Type:

str

certificate_pem

The certificate data, in PEM format.

Type:

str

class awsiot.iotidentity.CreateCertificateFromCsrSubscriptionRequest(*args, **kwargs)

Bases: ModeledClass

Data needed to subscribe to the responses of the CreateCertificateFromCsr operation.

This class has no attributes.

class awsiot.iotidentity.CreateKeysAndCertificateRequest(*args, **kwargs)

Bases: ModeledClass

Data needed to perform a CreateKeysAndCertificate operation.

This class has no attributes.

class awsiot.iotidentity.CreateKeysAndCertificateResponse(*args, **kwargs)

Bases: ModeledClass

Response payload to a CreateKeysAndCertificate request.

All attributes are None by default, and may be set by keyword in the constructor.

Keyword Arguments:
  • certificate_id (str) – The certificate id.

  • certificate_ownership_token (str) – The token to prove ownership of the certificate during provisioning.

  • certificate_pem (str) – The certificate data, in PEM format.

  • private_key (str) – The private key.

certificate_id

The certificate id.

Type:

str

certificate_ownership_token

The token to prove ownership of the certificate during provisioning.

Type:

str

certificate_pem

The certificate data, in PEM format.

Type:

str

private_key

The private key.

Type:

str

class awsiot.iotidentity.CreateKeysAndCertificateSubscriptionRequest(*args, **kwargs)

Bases: ModeledClass

Data needed to subscribe to the responses of the CreateKeysAndCertificate operation.

This class has no attributes.

class awsiot.iotidentity.ErrorResponse(*args, **kwargs)

Bases: ModeledClass

Response document containing details about a failed request.

All attributes are None by default, and may be set by keyword in the constructor.

Keyword Arguments:
  • error_code (str) – Response error code

  • error_message (str) – Response error message

  • status_code (int) – Response status code

error_code

Response error code

Type:

str

error_message

Response error message

Type:

str

status_code

Response status code

Type:

int

class awsiot.iotidentity.RegisterThingRequest(*args, **kwargs)

Bases: ModeledClass

Data needed to perform a RegisterThing operation.

All attributes are None by default, and may be set by keyword in the constructor.

Keyword Arguments:
  • certificate_ownership_token (str) – The token to prove ownership of the certificate. The token is generated by AWS IoT when you create a certificate over MQTT.

  • parameters (Dict[str, str]) – Optional. Key-value pairs from the device that are used by the pre-provisioning hooks to evaluate the registration request.

  • template_name (str) – The provisioning template name.

certificate_ownership_token

The token to prove ownership of the certificate. The token is generated by AWS IoT when you create a certificate over MQTT.

Type:

str

parameters

Optional. Key-value pairs from the device that are used by the pre-provisioning hooks to evaluate the registration request.

Type:

Dict[str, str]

template_name

The provisioning template name.

Type:

str

class awsiot.iotidentity.RegisterThingResponse(*args, **kwargs)

Bases: ModeledClass

Response payload to a RegisterThing request.

All attributes are None by default, and may be set by keyword in the constructor.

Keyword Arguments:
  • device_configuration (Dict[str, str]) – The device configuration defined in the template.

  • thing_name (str) – The name of the IoT thing created during provisioning.

device_configuration

The device configuration defined in the template.

Type:

Dict[str, str]

thing_name

The name of the IoT thing created during provisioning.

Type:

str

class awsiot.iotidentity.RegisterThingSubscriptionRequest(*args, **kwargs)

Bases: ModeledClass

Data needed to subscribe to the responses of the RegisterThing operation.

All attributes are None by default, and may be set by keyword in the constructor.

Keyword Arguments:

template_name (str) – Name of the provisioning template to listen for RegisterThing responses for.

template_name

Name of the provisioning template to listen for RegisterThing responses for.

Type:

str