An API client for AWS IoT SiteWise. To construct a client, you need to configure a :region
and :credentials
.
iotsitewise = Aws::IoTSiteWise::Client.new(
region: region_name,
credentials: credentials,
)
See #initialize for a full list of supported configuration options.
RegionYou can configure a default region in the following locations:
ENV['AWS_REGION']
Aws.config[:region]
Go here for a list of supported regions.
CredentialsDefault credentials are loaded automatically from the following locations:
ENV['AWS_ACCESS_KEY_ID']
and ENV['AWS_SECRET_ACCESS_KEY']
Aws.config[:credentials]
~/.aws/credentials
(more information)You can also construct a credentials object from one of the following classes:
Alternatively, you configure credentials with :access_key_id
and :secret_access_key
:
creds = YAML.load(File.read('/path/to/secrets'))
Aws::IoTSiteWise::Client.new(
access_key_id: creds['access_key_id'],
secret_access_key: creds['secret_access_key']
)
Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.
Instance Method Details #associate_assets(options = {}) ⇒ StructAssociates a child asset with the given parent asset through a hierarchy defined in the parent asset's model. For more information, see Associating assets in the AWS IoT SiteWise User Guide.
#batch_put_asset_property_value(options = {}) ⇒ Types::BatchPutAssetPropertyValueResponseSends a list of asset property values to AWS IoT SiteWise. Each value is a timestamp-quality-value (TQV) data point. For more information, see Ingesting data using the API in the AWS IoT SiteWise User Guide.
To identify an asset property, you must specify one of the following:
The assetId
and propertyId
of an asset property.
A propertyAlias
, which is a data stream alias (for example, /company/windfarm/3/turbine/7/temperature
). To define an asset property's alias, see UpdateAssetProperty.
With respect to Unix epoch time, AWS IoT SiteWise accepts only TQVs that have a timestamp of no more than 15 minutes in the past and no more than 5 minutes in the future. AWS IoT SiteWise rejects timestamps outside of the inclusive range of [-15, +5] minutes and returns a TimestampOutOfRangeException
error.
For each asset property, AWS IoT SiteWise overwrites TQVs with duplicate timestamps unless the newer TQV has a different quality. For example, if you store a TQV {T1, GOOD, V1}
, then storing {T1, GOOD, V2}
replaces the existing TQV.
AWS IoT SiteWise authorizes access to each BatchPutAssetPropertyValue
entry individually. For more information, see BatchPutAssetPropertyValue authorization in the AWS IoT SiteWise User Guide.
Creates an access policy that grants the specified identity (AWS SSO user, AWS SSO group, or IAM user) access to the specified AWS IoT SiteWise Monitor portal or project resource.
#create_asset_model(options = {}) ⇒ Types::CreateAssetModelResponseCreates an asset model from specified property and hierarchy definitions. You create assets from asset models. With asset models, you can easily create assets of the same type that have standardized definitions. Each asset created from a model inherits the asset model's property and hierarchy definitions. For more information, see Defining asset models in the AWS IoT SiteWise User Guide.
#create_portal(options = {}) ⇒ Types::CreatePortalResponseCreates a portal, which can contain projects and dashboards. AWS IoT SiteWise Monitor uses AWS SSO or IAM to authenticate portal users and manage user permissions.
Before you can sign in to a new portal, you must add at least one identity to that portal. For more information, see Adding or removing portal administrators in the AWS IoT SiteWise User Guide.
#create_presigned_portal_url(options = {}) ⇒ Types::CreatePresignedPortalUrlResponseCreates a pre-signed URL to a portal. Use this operation to create URLs to portals that use AWS Identity and Access Management (IAM) to authenticate users. An IAM user with access to a portal can call this API to get a URL to that portal. The URL contains a session token that lets the IAM user access the portal.
#delete_access_policy(options = {}) ⇒ StructDeletes an access policy that grants the specified identity access to the specified AWS IoT SiteWise Monitor resource. You can use this operation to revoke access to an AWS IoT SiteWise Monitor resource.
#delete_asset_model(options = {}) ⇒ Types::DeleteAssetModelResponseDeletes an asset model. This action can't be undone. You must delete all assets created from an asset model before you can delete the model. Also, you can't delete an asset model if a parent asset model exists that contains a property formula expression that depends on the asset model that you want to delete. For more information, see Deleting assets and models in the AWS IoT SiteWise User Guide.
#delete_dashboard(options = {}) ⇒ StructDeletes a dashboard from AWS IoT SiteWise Monitor.
#delete_gateway(options = {}) ⇒ StructDeletes a gateway from AWS IoT SiteWise. When you delete a gateway, some of the gateway's files remain in your gateway's file system.
#delete_project(options = {}) ⇒ StructDeletes a project from AWS IoT SiteWise Monitor.
#describe_access_policy(options = {}) ⇒ Types::DescribeAccessPolicyResponseDescribes an access policy, which specifies an identity's access to an AWS IoT SiteWise Monitor portal or project.
#describe_asset_property(options = {}) ⇒ Types::DescribeAssetPropertyResponseRetrieves information about an asset property.
When you call this operation for an attribute property, this response includes the default attribute value that you define in the asset model. If you update the default value in the model, this operation's response includes the new default value.
This operation doesn't return the value of the asset property. To get the value of an asset property, use GetAssetPropertyValue.
#describe_gateway_capability_configuration(options = {}) ⇒ Types::DescribeGatewayCapabilityConfigurationResponseRetrieves information about a gateway capability configuration. Each gateway capability defines data sources for a gateway. A capability configuration can contain multiple data source configurations. If you define OPC-UA sources for a gateway in the AWS IoT SiteWise console, all of your OPC-UA sources are stored in one capability configuration. To list all capability configurations for a gateway, use DescribeGateway.
#disassociate_assets(options = {}) ⇒ StructDisassociates a child asset from the given parent asset through a hierarchy defined in the parent asset's model.
#get_asset_property_aggregates(options = {}) ⇒ Types::GetAssetPropertyAggregatesResponseGets aggregated values for an asset property. For more information, see Querying aggregates in the AWS IoT SiteWise User Guide.
To identify an asset property, you must specify one of the following:
The assetId
and propertyId
of an asset property.
A propertyAlias
, which is a data stream alias (for example, /company/windfarm/3/turbine/7/temperature
). To define an asset property's alias, see UpdateAssetProperty.
Gets an asset property's current value. For more information, see Querying current values in the AWS IoT SiteWise User Guide.
To identify an asset property, you must specify one of the following:
The assetId
and propertyId
of an asset property.
A propertyAlias
, which is a data stream alias (for example, /company/windfarm/3/turbine/7/temperature
). To define an asset property's alias, see UpdateAssetProperty.
Gets the history of an asset property's values. For more information, see Querying historical values in the AWS IoT SiteWise User Guide.
To identify an asset property, you must specify one of the following:
The assetId
and propertyId
of an asset property.
A propertyAlias
, which is a data stream alias (for example, /company/windfarm/3/turbine/7/temperature
). To define an asset property's alias, see UpdateAssetProperty.
Retrieves a paginated list of access policies for an identity (an AWS SSO user, an AWS SSO group, or an IAM user) or an AWS IoT SiteWise Monitor resource (a portal or project).
#list_assets(options = {}) ⇒ Types::ListAssetsResponseRetrieves a paginated list of asset summaries.
You can use this operation to do the following:
List assets based on a specific asset model.
List top-level assets.
You can't use this operation to list all assets. To retrieve summaries for all of your assets, use ListAssetModels to get all of your asset model IDs. Then, use ListAssets to get all assets for each asset model.
#list_associated_assets(options = {}) ⇒ Types::ListAssociatedAssetsResponseRetrieves a paginated list of associated assets.
You can use this operation to do the following:
List child assets associated to a parent asset by a hierarchy that you specify.
List an asset's parent asset.
Retrieves a paginated list of projects for an AWS IoT SiteWise Monitor portal.
#put_logging_options(options = {}) ⇒ StructSets logging options for AWS IoT SiteWise.
#tag_resource(options = {}) ⇒ StructAdds tags to an AWS IoT SiteWise resource. If a tag already exists for the resource, this operation updates the tag's value.
#untag_resource(options = {}) ⇒ StructRemoves a tag from an AWS IoT SiteWise resource.
#update_access_policy(options = {}) ⇒ StructUpdates an existing access policy that specifies an identity's access to an AWS IoT SiteWise Monitor portal or project resource.
#update_asset_model(options = {}) ⇒ Types::UpdateAssetModelResponseUpdates an asset model and all of the assets that were created from the model. Each asset created from the model inherits the updated asset model's property and hierarchy definitions. For more information, see Updating assets and models in the AWS IoT SiteWise User Guide.
This operation overwrites the existing model with the provided model. To avoid deleting your asset model's properties or hierarchies, you must include their IDs and definitions in the updated asset model payload. For more information, see DescribeAssetModel.
If you remove a property from an asset model, AWS IoT SiteWise deletes all previous data for that property. If you remove a hierarchy definition from an asset model, AWS IoT SiteWise disassociates every asset associated with that hierarchy. You can't change the type or data type of an existing property.
#update_asset_property(options = {}) ⇒ StructUpdates an asset property's alias and notification state.
This operation overwrites the property's existing alias and notification state. To keep your existing property's alias or notification state, you must include the existing values in the UpdateAssetProperty request. For more information, see DescribeAssetProperty.
#update_dashboard(options = {}) ⇒ StructUpdates an AWS IoT SiteWise Monitor dashboard.
#update_gateway(options = {}) ⇒ StructUpdates a gateway's name.
#update_gateway_capability_configuration(options = {}) ⇒ Types::UpdateGatewayCapabilityConfigurationResponseUpdates a gateway capability configuration or defines a new capability configuration. Each gateway capability defines data sources for a gateway. A capability configuration can contain multiple data source configurations. If you define OPC-UA sources for a gateway in the AWS IoT SiteWise console, all of your OPC-UA sources are stored in one capability configuration. To list all capability configurations for a gateway, use DescribeGateway.
#update_project(options = {}) ⇒ StructUpdates an AWS IoT SiteWise Monitor project.
#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ BooleanWaiters polls an API operation until a resource enters a desired state.
Basic UsageWaiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)
ConfigurationYou can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:
# poll for ~25 seconds
client.wait_until(...) do |w|
w.max_attempts = 5
w.delay = 5
end
Callbacks
You can be notified before each polling attempt and before each delay. If you throw :success
or :failure
from these callbacks, it will terminate the waiter.
started_at = Time.now
client.wait_until(...) do |w|
# disable max attempts
w.max_attempts = nil
# poll for 1 hour, instead of a number of attempts
w.before_wait do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
end
Handling Errors
When a waiter is successful, it returns true
. When a waiter fails, it raises an error. All errors raised extend from Waiters::Errors::WaiterFailed.
begin
client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
#waiter_names ⇒ Array<Symbol>
Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4