Skip to content

create_asset

create_asset(
    asset_name: Name,
    asset_model_id: CustomID,
    *,
    config_overrides: Optional[IoTSiteWiseClientConfig] = None,
    asset_id: Optional[ID] = None,
    asset_external_id: Optional[ExternalId] = None,
    client_token: Optional[ClientToken] = None,
    tags: Optional[TagMap] = None,
    asset_description: Optional[Description] = None,
) -> CreateAssetResponse

Creates an asset from an existing asset model. For more information, see Creating assets in the IoT SiteWise User Guide.

Parameters:

  • asset_name (Name) –

    A friendly name for the asset.

  • asset_model_id (CustomID) –

    The ID of the asset model from which to create the asset. This can be either the actual ID in UUID format, or else externalId: followed by the external ID, if it has one. For more information, see Referencing objects with external IDs in the IoT SiteWise User Guide.

  • asset_id (Optional[ID], default: None ) –

    The ID to assign to the asset, if desired. IoT SiteWise automatically generates a unique ID for you, so this parameter is never required. However, if you prefer to supply your own ID instead, you can specify it here in UUID format. If you specify your own ID, it must be globally unique.

  • asset_external_id (Optional[ExternalId], default: None ) –

    An external ID to assign to the asset. The external ID must be unique within your Amazon Web Services account. For more information, see Using external IDs in the IoT SiteWise User Guide.

  • client_token (Optional[ClientToken], default: None ) –

    A unique case-sensitive identifier that you can provide to ensure the idempotency of the request. Don't reuse this client token if a new idempotent request is required.

  • tags (Optional[TagMap], default: None ) –

    A list of key-value pairs that contain metadata for the asset. For more information, see Tagging your IoT SiteWise resources in the IoT SiteWise User Guide.

  • asset_description (Optional[Description], default: None ) –

    A description for the asset.

Raises:

  • ConflictingOperationException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.

  • InternalFailureException –

    IoT SiteWise can't process your request right now. Try again later.

  • InvalidRequestException –

    The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.

  • LimitExceededException –

    You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • ResourceAlreadyExistsException –

    The resource already exists.

  • ResourceNotFoundException –

    The requested resource can't be found.

  • ThrottlingException –

    Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_iotsitewise/_services/io_t_site_wise.py
def create_asset(
    self,
    asset_name: "capo_iotsitewise.types.name.Name",
    asset_model_id: "capo_iotsitewise.types.custom_id.CustomID",
    *,
    config_overrides: Optional[IoTSiteWiseClientConfig] = None,
    asset_id: Optional["capo_iotsitewise.types.id.ID"] = None,
    asset_external_id: Optional[
        "capo_iotsitewise.types.external_id.ExternalId"
    ] = None,
    client_token: Optional[
        "capo_iotsitewise.types.client_token.ClientToken"
    ] = None,
    tags: Optional["capo_iotsitewise.types.tag_map.TagMap"] = None,
    asset_description: Optional[
        "capo_iotsitewise.types.description.Description"
    ] = None,
) -> "capo_iotsitewise.types.create_asset_response.CreateAssetResponse":
    """<p>Creates an asset from an existing asset model. For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/create-assets.html">Creating assets</a> in the <i>IoT SiteWise User Guide</i>.</p>

    Args:
        asset_name: <p>A friendly name for the asset.</p>
        asset_model_id: <p>The ID of the asset model from which to create the asset. This can be either the actual ID in UUID format, or else <code>externalId:</code> followed by the external ID, if it has one. For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/object-ids.html#external-id-references">Referencing objects with external IDs</a> in the <i>IoT SiteWise User Guide</i>.</p>
        asset_id: <p>The ID to assign to the asset, if desired. IoT SiteWise automatically generates a unique ID for you, so this parameter is never required. However, if you prefer to supply your own ID instead, you can specify it here in UUID format. If you specify your own ID, it must be globally unique.</p>
        asset_external_id: <p>An external ID to assign to the asset. The external ID must be unique within your Amazon Web Services account. For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/object-ids.html#external-ids">Using external IDs</a> in the <i>IoT SiteWise User Guide</i>.</p>
        client_token: <p>A unique case-sensitive identifier that you can provide to ensure the idempotency of the request. Don't reuse this client token if a new idempotent request is required.</p>
        tags: <p>A list of key-value pairs that contain metadata for the asset. For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/tag-resources.html">Tagging your IoT SiteWise resources</a> in the <i>IoT SiteWise User Guide</i>.</p>
        asset_description: <p>A description for the asset.</p>

    Raises:
        capo_iotsitewise.errors.conflicting_operation_exception.ConflictingOperationException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.</p>
        capo_iotsitewise.errors.internal_failure_exception.InternalFailureException: <p>IoT SiteWise can't process your request right now. Try again later.</p>
        capo_iotsitewise.errors.invalid_request_exception.InvalidRequestException: <p>The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.</p>
        capo_iotsitewise.errors.limit_exceeded_exception.LimitExceededException: <p>You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource already exists.</p>
        capo_iotsitewise.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource can't be found.</p>
        capo_iotsitewise.errors.throttling_exception.ThrottlingException: <p>Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_iotsitewise.types.create_asset_request.CreateAssetRequest]",
    ) -> OperationResponse[
        "capo_iotsitewise.types.create_asset_response.CreateAssetResponse"
    ]:
        import capo_iotsitewise._operations.aws_io_t_site_wise.create_asset

        output, http_response = (
            capo_iotsitewise._operations.aws_io_t_site_wise.create_asset.create_asset(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAsset")
    )
    input_: capo_iotsitewise.types.create_asset_request.CreateAssetRequest = {
        "asset_name": asset_name,
        "asset_model_id": asset_model_id,
    }
    if asset_id is not None:
        input_["asset_id"] = asset_id
    if asset_external_id is not None:
        input_["asset_external_id"] = asset_external_id
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags
    if asset_description is not None:
        input_["asset_description"] = asset_description

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output