AWS IoT

2021/08/31 - AWS IoT - 6 new 1 updated api methods

Changes  Added Create/Update/Delete/Describe/List APIs for a new IoT resource named FleetMetric. Added a new Fleet Indexing query API named GetBucketsAggregation. Added a new field named DisconnectedReason in Fleet Indexing query response. Updated their related documentations.

GetBucketsAggregation (new) Link ¶

Aggregates on indexed data with search queries pertaining to particular fields.

Requires permission to access the GetBucketsAggregation action.

See also: AWS API Documentation

Request Syntax

client.get_buckets_aggregation(
    indexName='string',
    queryString='string',
    aggregationField='string',
    queryVersion='string',
    bucketsAggregationType={
        'termsAggregation': {
            'maxBuckets': 123
        }
    }
)
type indexName

string

param indexName

The name of the index to search.

type queryString

string

param queryString

[REQUIRED]

The search query string.

type aggregationField

string

param aggregationField

[REQUIRED]

The aggregation field.

type queryVersion

string

param queryVersion

The version of the query.

type bucketsAggregationType

dict

param bucketsAggregationType

[REQUIRED]

The basic control of the response shape and the bucket aggregation type to perform.

  • termsAggregation (dict) --

    Performs an aggregation that will return a list of buckets. The list of buckets is a ranked list of the number of occurrences of an aggregation field value.

    • maxBuckets (integer) --

      The number of buckets to return in the response. Default to 10.

rtype

dict

returns

Response Syntax

{
    'totalCount': 123,
    'buckets': [
        {
            'keyValue': 'string',
            'count': 123
        },
    ]
}

Response Structure

  • (dict) --

    • totalCount (integer) --

      The total number of documents that fit the query string criteria and contain a value for the Aggregation field targeted in the request.

    • buckets (list) --

      The main part of the response with a list of buckets. Each bucket contains a keyValue and a count .

      keyValue : The aggregation field value counted for the particular bucket.

      count : The number of documents that have that value.

      • (dict) --

        A count of documents that meets a specific aggregation criteria.

        • keyValue (string) --

          The value counted for the particular bucket.

        • count (integer) --

          The number of documents that have the value counted for the particular bucket.

DeleteFleetMetric (new) Link ¶

Deletes the specified fleet metric. Returns successfully with no error if the deletion is successful or you specify a fleet metric that doesn't exist.

Requires permission to access the DeleteFleetMetric action.

See also: AWS API Documentation

Request Syntax

client.delete_fleet_metric(
    metricName='string',
    expectedVersion=123
)
type metricName

string

param metricName

[REQUIRED]

The name of the fleet metric to delete.

type expectedVersion

integer

param expectedVersion

The expected version of the fleet metric to delete.

returns

None

UpdateFleetMetric (new) Link ¶

Updates the data for a fleet metric.

Requires permission to access the UpdateFleetMetric action.

See also: AWS API Documentation

Request Syntax

client.update_fleet_metric(
    metricName='string',
    queryString='string',
    aggregationType={
        'name': 'Statistics'|'Percentiles'|'Cardinality',
        'values': [
            'string',
        ]
    },
    period=123,
    aggregationField='string',
    description='string',
    queryVersion='string',
    indexName='string',
    unit='Seconds'|'Microseconds'|'Milliseconds'|'Bytes'|'Kilobytes'|'Megabytes'|'Gigabytes'|'Terabytes'|'Bits'|'Kilobits'|'Megabits'|'Gigabits'|'Terabits'|'Percent'|'Count'|'Bytes/Second'|'Kilobytes/Second'|'Megabytes/Second'|'Gigabytes/Second'|'Terabytes/Second'|'Bits/Second'|'Kilobits/Second'|'Megabits/Second'|'Gigabits/Second'|'Terabits/Second'|'Count/Second'|'None',
    expectedVersion=123
)
type metricName

string

param metricName

[REQUIRED]

The name of the fleet metric to update.

type queryString

string

param queryString

The search query string.

type aggregationType

dict

param aggregationType

The type of the aggregation query.

  • name (string) -- [REQUIRED]

    The name of the aggregation type.

  • values (list) --

    A list of the values of aggregation types.

    • (string) --

type period

integer

param period

The time in seconds between fleet metric emissions. Range [60(1 min), 86400(1 day)] and must be multiple of 60.

type aggregationField

string

param aggregationField

The field to aggregate.

type description

string

param description

The description of the fleet metric.

type queryVersion

string

param queryVersion

The version of the query.

type indexName

string

param indexName

[REQUIRED]

The name of the index to search.

type unit

string

param unit

Used to support unit transformation such as milliseconds to seconds. The unit must be supported by CW metric.

type expectedVersion

integer

param expectedVersion

The expected version of the fleet metric record in the registry.

returns

None

DescribeFleetMetric (new) Link ¶

Gets information about the specified fleet metric.

Requires permission to access the DescribeFleetMetric action.

See also: AWS API Documentation

Request Syntax

client.describe_fleet_metric(
    metricName='string'
)
type metricName

string

param metricName

[REQUIRED]

The name of the fleet metric to describe.

rtype

dict

returns

Response Syntax

{
    'metricName': 'string',
    'queryString': 'string',
    'aggregationType': {
        'name': 'Statistics'|'Percentiles'|'Cardinality',
        'values': [
            'string',
        ]
    },
    'period': 123,
    'aggregationField': 'string',
    'description': 'string',
    'queryVersion': 'string',
    'indexName': 'string',
    'creationDate': datetime(2015, 1, 1),
    'lastModifiedDate': datetime(2015, 1, 1),
    'unit': 'Seconds'|'Microseconds'|'Milliseconds'|'Bytes'|'Kilobytes'|'Megabytes'|'Gigabytes'|'Terabytes'|'Bits'|'Kilobits'|'Megabits'|'Gigabits'|'Terabits'|'Percent'|'Count'|'Bytes/Second'|'Kilobytes/Second'|'Megabytes/Second'|'Gigabytes/Second'|'Terabytes/Second'|'Bits/Second'|'Kilobits/Second'|'Megabits/Second'|'Gigabits/Second'|'Terabits/Second'|'Count/Second'|'None',
    'version': 123,
    'metricArn': 'string'
}

Response Structure

  • (dict) --

    • metricName (string) --

      The name of the fleet metric to describe.

    • queryString (string) --

      The search query string.

    • aggregationType (dict) --

      The type of the aggregation query.

      • name (string) --

        The name of the aggregation type.

      • values (list) --

        A list of the values of aggregation types.

        • (string) --

    • period (integer) --

      The time in seconds between fleet metric emissions. Range [60(1 min), 86400(1 day)] and must be multiple of 60.

    • aggregationField (string) --

      The field to aggregate.

    • description (string) --

      The fleet metric description.

    • queryVersion (string) --

      The query version.

    • indexName (string) --

      The name of the index to search.

    • creationDate (datetime) --

      The date when the fleet metric is created.

    • lastModifiedDate (datetime) --

      The date when the fleet metric is last modified.

    • unit (string) --

      Used to support unit transformation such as milliseconds to seconds. The unit must be supported by CW metric.

    • version (integer) --

      The version of the fleet metric.

    • metricArn (string) --

      The ARN of the fleet metric to describe.

ListFleetMetrics (new) Link ¶

Lists all your fleet metrics.

Requires permission to access the ListFleetMetrics action.

See also: AWS API Documentation

Request Syntax

client.list_fleet_metrics(
    nextToken='string',
    maxResults=123
)
type nextToken

string

param nextToken

To retrieve the next set of results, the nextToken value from a previous response; otherwise null to receive the first set of results.

type maxResults

integer

param maxResults

The maximum number of results to return in this operation.

rtype

dict

returns

Response Syntax

{
    'fleetMetrics': [
        {
            'metricName': 'string',
            'metricArn': 'string'
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) --

    • fleetMetrics (list) --

      The list of fleet metrics objects.

      • (dict) --

        The name and ARN of a fleet metric.

        • metricName (string) --

          The fleet metric name.

        • metricArn (string) --

          The fleet metric ARN.

    • nextToken (string) --

      The token for the next set of results. Will not be returned if the operation has returned all results.

CreateFleetMetric (new) Link ¶

Creates a fleet metric.

Requires permission to access the CreateFleetMetric action.

See also: AWS API Documentation

Request Syntax

client.create_fleet_metric(
    metricName='string',
    queryString='string',
    aggregationType={
        'name': 'Statistics'|'Percentiles'|'Cardinality',
        'values': [
            'string',
        ]
    },
    period=123,
    aggregationField='string',
    description='string',
    queryVersion='string',
    indexName='string',
    unit='Seconds'|'Microseconds'|'Milliseconds'|'Bytes'|'Kilobytes'|'Megabytes'|'Gigabytes'|'Terabytes'|'Bits'|'Kilobits'|'Megabits'|'Gigabits'|'Terabits'|'Percent'|'Count'|'Bytes/Second'|'Kilobytes/Second'|'Megabytes/Second'|'Gigabytes/Second'|'Terabytes/Second'|'Bits/Second'|'Kilobits/Second'|'Megabits/Second'|'Gigabits/Second'|'Terabits/Second'|'Count/Second'|'None',
    tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type metricName

string

param metricName

[REQUIRED]

The name of the fleet metric to create.

type queryString

string

param queryString

[REQUIRED]

The search query string.

type aggregationType

dict

param aggregationType

[REQUIRED]

The type of the aggregation query.

  • name (string) -- [REQUIRED]

    The name of the aggregation type.

  • values (list) --

    A list of the values of aggregation types.

    • (string) --

type period

integer

param period

[REQUIRED]

The time in seconds between fleet metric emissions. Range [60(1 min), 86400(1 day)] and must be multiple of 60.

type aggregationField

string

param aggregationField

[REQUIRED]

The field to aggregate.

type description

string

param description

The fleet metric description.

type queryVersion

string

param queryVersion

The query version.

type indexName

string

param indexName

The name of the index to search.

type unit

string

param unit

Used to support unit transformation such as milliseconds to seconds. The unit must be supported by CW metric. Default to null.

type tags

list

param tags

Metadata, which can be used to manage the fleet metric.

  • (dict) --

    A set of key/value pairs that are used to manage the resource.

    • Key (string) -- [REQUIRED]

      The tag's key.

    • Value (string) --

      The tag's value.

rtype

dict

returns

Response Syntax

{
    'metricName': 'string',
    'metricArn': 'string'
}

Response Structure

  • (dict) --

    • metricName (string) --

      The name of the fleet metric to create.

    • metricArn (string) --

      The Amazon Resource Name (ARN) of the new fleet metric.

SearchIndex (updated) Link ¶
Changes (response)
{'things': {'connectivity': {'disconnectReason': 'string'}}}

The query search index.

Requires permission to access the SearchIndex action.

See also: AWS API Documentation

Request Syntax

client.search_index(
    indexName='string',
    queryString='string',
    nextToken='string',
    maxResults=123,
    queryVersion='string'
)
type indexName

string

param indexName

The search index name.

type queryString

string

param queryString

[REQUIRED]

The search query string.

type nextToken

string

param nextToken

The token used to get the next set of results, or null if there are no additional results.

type maxResults

integer

param maxResults

The maximum number of results to return at one time.

type queryVersion

string

param queryVersion

The query version.

rtype

dict

returns

Response Syntax

{
    'nextToken': 'string',
    'things': [
        {
            'thingName': 'string',
            'thingId': 'string',
            'thingTypeName': 'string',
            'thingGroupNames': [
                'string',
            ],
            'attributes': {
                'string': 'string'
            },
            'shadow': 'string',
            'connectivity': {
                'connected': True|False,
                'timestamp': 123,
                'disconnectReason': 'string'
            }
        },
    ],
    'thingGroups': [
        {
            'thingGroupName': 'string',
            'thingGroupId': 'string',
            'thingGroupDescription': 'string',
            'attributes': {
                'string': 'string'
            },
            'parentGroupNames': [
                'string',
            ]
        },
    ]
}

Response Structure

  • (dict) --

    • nextToken (string) --

      The token used to get the next set of results, or null if there are no additional results.

    • things (list) --

      The things that match the search query.

      • (dict) --

        The thing search index document.

        • thingName (string) --

          The thing name.

        • thingId (string) --

          The thing ID.

        • thingTypeName (string) --

          The thing type name.

        • thingGroupNames (list) --

          Thing group names.

          • (string) --

        • attributes (dict) --

          The attributes.

          • (string) --

            • (string) --

        • shadow (string) --

          The shadow.

        • connectivity (dict) --

          Indicates whether the thing is connected to the Amazon Web Services IoT Core service.

          • connected (boolean) --

            True if the thing is connected to the Amazon Web Services IoT Core service; false if it is not connected.

          • timestamp (integer) --

            The epoch time (in milliseconds) when the thing last connected or disconnected. If the thing has been disconnected for approximately an hour, the time value might be missing.

          • disconnectReason (string) --

            The reason why the client is disconnected.

    • thingGroups (list) --

      The thing groups that match the search query.

      • (dict) --

        The thing group search index document.

        • thingGroupName (string) --

          The thing group name.

        • thingGroupId (string) --

          The thing group ID.

        • thingGroupDescription (string) --

          The thing group description.

        • attributes (dict) --

          The thing group attributes.

          • (string) --

            • (string) --

        • parentGroupNames (list) --

          Parent group names.

          • (string) --