Skip to content

Commit

Permalink
Merge pull request aws#4220 from bisdavid/iot
Browse files Browse the repository at this point in the history
Several new IOT examples
  • Loading branch information
stealthycoin authored Jun 6, 2019
2 parents 8f7dedb + 7fe6f1a commit 069c7f9
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 0 deletions.
17 changes: 17 additions & 0 deletions awscli/examples/iot/create-thing-type.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**To define a thing type**

The following ``create-thing-type`` example defines a thing type and associated attributes. ::

aws iot create-thing-type \
--thing-type-name "LightBulb" \
--thing-type-properties "thingTypeDescription=light bulb type, searchableAttributes=wattage,model"

Output::

{
"thingTypeName": "LightBulb",
"thingTypeArn": "arn:aws:iot:us-west-2:123456789012:thingtype/LightBulb",
"thingTypeId": "ce3573b0-0a3c-45a7-ac93-4e0ce14cd190"
}

For more information, see `Thing Types <https://docs.aws.amazon.com/iot/latest/developerguide/thing-types.html>`__ in the *AWS IoT Developers Guide*.
33 changes: 33 additions & 0 deletions awscli/examples/iot/create-thing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
**Example 1: To create a thing record in the registry**

The following ``create-thing`` example creates an entry for a device in the AWS IoT thing registry. ::

aws iot create-thing \
--thing-name SampleIoTThing

Output::

{
"thingName": "SampleIoTThing",
"thingArn": "arn:aws:iot:us-west-2: 123456789012:thing/SampleIoTThing",
"thingId": " EXAMPLE1-90ab-cdef-fedc-ba987EXAMPLE "
}

**Example 2: To define a thing that is associated with a thing type**

The following ``create-thing`` example create a thing that has the specified thing type and its attributes. ::

aws iot create-thing \
--thing-name "MyLightBulb" \
--thing-type-name "LightBulb" \
--attribute-payload "{"attributes": {"wattage":"75", "model":"123"}}"

Output::

{
"thingName": "MyLightBulb",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyLightBulb",
"thingId": "40da2e73-c6af-406e-b415-15acae538797"
}

For more information, see `How to Manage Things with the Registry <https://docs.aws.amazon.com/iot/latest/developerguide/thing-registry.html>`__ and `Thing Types <https://docs.aws.amazon.com/iot/latest/developerguide/thing-types.html>`__ in the *AWS IoT Developers Guide*.
9 changes: 9 additions & 0 deletions awscli/examples/iot/delete-thing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**To display detailed information about a thing**

The following ``delete-thing`` example deletes a thing from the AWS IoT registry for your AWS account.

aws iot delete-thing --thing-name "FourthBulb"

This command produces no output.

For more information, see `How to Manage Things with the Registry <https://docs.aws.amazon.com/iot/latest/developerguide/thing-registry.html>`__ in the *AWS IoT Developers Guide*.
27 changes: 27 additions & 0 deletions awscli/examples/iot/describe-thing-type.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
**To get information about a thing type**

The following ``describe-thing-type`` example display information about the specified thing type defined in your AWS account. ::

aws iot describe-thing-type \
--thing-type-name "LightBulb"

Output::

{
"thingTypeName": "LightBulb",
"thingTypeId": "ce3573b0-0a3c-45a7-ac93-4e0ce14cd190",
"thingTypeArn": "arn:aws:iot:us-west-2:123456789012:thingtype/LightBulb",
"thingTypeProperties": {
"thingTypeDescription": "light bulb type",
"searchableAttributes": [
"model",
"wattage"
]
},
"thingTypeMetadata": {
"deprecated": false,
"creationDate": 1559772562.498
}
}

For more information, see `Thing Types <https://docs.aws.amazon.com/iot/latest/developerguide/thing-types.html>`__ in the *AWS IoT Developers Guide*.
23 changes: 23 additions & 0 deletions awscli/examples/iot/describe-thing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**To display detailed information about a thing**

The following ``describe-thing`` example display information about a thing (device) that is defined in the AWS IoT registry for your AWS account.

aws iot describe-thing \
--thing-name "MyLightBulb"

Output::

{
"defaultClientId": "MyLightBulb",
"thingName": "MyLightBulb",
"thingId": "40da2e73-c6af-406e-b415-15acae538797",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyLightBulb",
"thingTypeName": "LightBulb",
"attributes": {
"model": "123",
"wattage": "75"
},
"version": 1
}

For more information, see `How to Manage Things with the Registry <https://docs.aws.amazon.com/iot/latest/developerguide/thing-registry.html>`__ in the *AWS IoT Developers Guide*.
29 changes: 29 additions & 0 deletions awscli/examples/iot/list-thing-types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**To list the defined thing types**

The following ``list-thing-types`` example displays a list of thing types defined in your AWS account. ::

aws iot list-thing-types

Output::

{
"thingTypes": [
{
"thingTypeName": "LightBulb",
"thingTypeArn": "arn:aws:iot:us-west-2:123456789012:thingtype/LightBulb",
"thingTypeProperties": {
"thingTypeDescription": "light bulb type",
"searchableAttributes": [
"model",
"wattage"
]
},
"thingTypeMetadata": {
"deprecated": false,
"creationDate": 1559772562.498
}
}
]
}

For more information, see `Thing Types <https://docs.aws.amazon.com/iot/latest/developerguide/thing-types.html>`__ in the *AWS IoT Developers Guide*.
84 changes: 84 additions & 0 deletions awscli/examples/iot/list-things.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
**Example 1: To list all things in the registry**

The following ``list-things`` example lists the things (devices) that are defined in the AWS IoT registry for your AWS account. ::

aws iot list-things

Output::

{
"things": [
{
"thingName": "ThirdBulb",
"thingTypeName": "LightBulb",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/ThirdBulb",
"attributes": {
"model": "123",
"wattage": "75"
},
"version": 2
},
{
"thingName": "MyOtherLightBulb",
"thingTypeName": "LightBulb",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyOtherLightBulb",
"attributes": {
"model": "123",
"wattage": "75"
},
"version": 3
},
{
"thingName": "MyLightBulb",
"thingTypeName": "LightBulb",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyLightBulb",
"attributes": {
"model": "123",
"wattage": "75"
},
"version": 1
},
{
"thingName": "SampleIoTThing",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/SampleIoTThing",
"attributes": {},
"version": 1
}
]
}

**Example 2: To list the defined things that have a specific attribute**

The following ``list-things`` example displays a list of things that have an attribute named ``wattage``. ::

aws iot list-things \
--attribute-name wattage

Output::

{
"things": [
{
"thingName": "MyLightBulb",
"thingTypeName": "LightBulb",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyLightBulb",
"attributes": {
"model": "123",
"wattage": "75"
},
"version": 1
},
{
"thingName": "MyOtherLightBulb",
"thingTypeName": "LightBulb",
"thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyOtherLightBulb",
"attributes": {
"model": "123",
"wattage": "75"
},
"version": 3
}
]
}

For more information, see `How to Manage Things with the Registry <https://docs.aws.amazon.com/iot/latest/developerguide/thing-registry.html>`__ in the *AWS IoT Developers Guide*.
12 changes: 12 additions & 0 deletions awscli/examples/iot/update-thing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**To associate a thing with a thing type**

The following ``update-thing`` example associates a thing in the AWS IoT registry with a thing type. When you make the association, you provide values for the attributes defined by the thing type. ::

aws iot update-thing \
--thing-name "MyOtherLightBulb" \
--thing-type-name "LightBulb" \
--attribute-payload "{"attributes": {"wattage":"75", "model":"123"}}"

This command does not produce output. Use the ``describe-thing`` command to see the result.

For more information, see `Thing Types <https://docs.aws.amazon.com/iot/latest/developerguide/thing-types.html>`__ in the *AWS IoT Developers Guide*.

0 comments on commit 069c7f9

Please sign in to comment.