Skip to content

create_asset_model_composite_model

create_asset_model_composite_model(
    asset_model_id: CustomID,
    asset_model_composite_model_name: Name,
    asset_model_composite_model_type: Name,
    *,
    config_overrides: Optional[IoTSiteWiseClientConfig] = None,
    asset_model_composite_model_external_id: Optional[ExternalId] = None,
    parent_asset_model_composite_model_id: Optional[CustomID] = None,
    asset_model_composite_model_id: Optional[ID] = None,
    asset_model_composite_model_description: Optional[Description] = None,
    client_token: Optional[ClientToken] = None,
    composed_asset_model_id: Optional[CustomID] = None,
    asset_model_composite_model_properties: Optional[
        AssetModelPropertyDefinitions
    ] = None,
    if_match: Optional[ETag] = None,
    if_none_match: Optional[SelectAll] = None,
    match_for_version_type: Optional[AssetModelVersionType] = None,
) -> CreateAssetModelCompositeModelResponse

Creates a custom composite model from specified property and hierarchy definitions. There are two types of custom composite models, inline and component-model-based.

Use component-model-based custom composite models to define standard, reusable components. A component-model-based custom composite model consists of a name, a description, and the ID of the component model it references. A component-model-based custom composite model has no properties of its own; its referenced component model provides its associated properties to any created assets. For more information, see Custom composite models (Components) in the IoT SiteWise User Guide.

Use inline custom composite models to organize the properties of an asset model. The properties of inline custom composite models are local to the asset model where they are included and can't be used to create multiple assets.

To create a component-model-based model, specify the composedAssetModelId of an existing asset model with assetModelType of COMPONENT_MODEL.

To create an inline model, specify the assetModelCompositeModelProperties and don't include an composedAssetModelId.

Parameters:

  • asset_model_id (CustomID) –

    The ID of the asset model this composite model is a part of.

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

    An external ID to assign to the composite model.

    If the composite model is a derived composite model, or one nested inside a component model, you can only set the external ID using UpdateAssetModelCompositeModel and specifying the derived ID of the model or property from the created model it's a part of.

  • parent_asset_model_composite_model_id (Optional[CustomID], default: None ) –

    The ID of the parent composite model in this asset model relationship.

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

    The ID of the composite model. 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_model_composite_model_description (Optional[Description], default: None ) –

    A description for the composite model.

  • asset_model_composite_model_name (Name) –

    A unique name for the composite model.

  • asset_model_composite_model_type (Name) –

    The composite model type. Valid values are AWS/ALARM, CUSTOM, or AWS/L4E_ANOMALY.

  • 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.

  • composed_asset_model_id (Optional[CustomID], default: None ) –

    The ID of a component model which is reused to create this composite model.

  • asset_model_composite_model_properties (Optional[AssetModelPropertyDefinitions], default: None ) –

    The property definitions of the composite model. For more information, see Inline custom composite models in the IoT SiteWise User Guide.

    You can specify up to 200 properties per composite model. For more information, see Quotas in the IoT SiteWise User Guide.

  • if_match (Optional[ETag], default: None ) –

    The expected current entity tag (ETag) for the asset model’s latest or active version (specified using matchForVersionType). The create request is rejected if the tag does not match the latest or active version's current entity tag. See Optimistic locking for asset model writes in the IoT SiteWise User Guide.

  • if_none_match (Optional[SelectAll], default: None ) –

    Accepts * to reject the create request if an active version (specified using matchForVersionType as ACTIVE) already exists for the asset model.

  • match_for_version_type (Optional[AssetModelVersionType], default: None ) –

    Specifies the asset model version type (LATEST or ACTIVE) used in conjunction with If-Match or If-None-Match headers to determine the target ETag for the create operation.

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.

  • PreconditionFailedException –

    The precondition in one or more of the request-header fields evaluated to FALSE.

  • 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_model_composite_model(
    self,
    asset_model_id: "capo_iotsitewise.types.custom_id.CustomID",
    asset_model_composite_model_name: "capo_iotsitewise.types.name.Name",
    asset_model_composite_model_type: "capo_iotsitewise.types.name.Name",
    *,
    config_overrides: Optional[IoTSiteWiseClientConfig] = None,
    asset_model_composite_model_external_id: Optional[
        "capo_iotsitewise.types.external_id.ExternalId"
    ] = None,
    parent_asset_model_composite_model_id: Optional[
        "capo_iotsitewise.types.custom_id.CustomID"
    ] = None,
    asset_model_composite_model_id: Optional["capo_iotsitewise.types.id.ID"] = None,
    asset_model_composite_model_description: Optional[
        "capo_iotsitewise.types.description.Description"
    ] = None,
    client_token: Optional[
        "capo_iotsitewise.types.client_token.ClientToken"
    ] = None,
    composed_asset_model_id: Optional[
        "capo_iotsitewise.types.custom_id.CustomID"
    ] = None,
    asset_model_composite_model_properties: Optional[
        "capo_iotsitewise.types.asset_model_property_definitions.AssetModelPropertyDefinitions"
    ] = None,
    if_match: Optional["capo_iotsitewise.types.e_tag.ETag"] = None,
    if_none_match: Optional["capo_iotsitewise.types.select_all.SelectAll"] = None,
    match_for_version_type: Optional[
        "capo_iotsitewise.types.asset_model_version_type.AssetModelVersionType"
    ] = None,
) -> "capo_iotsitewise.types.create_asset_model_composite_model_response.CreateAssetModelCompositeModelResponse":
    """<p>Creates a custom composite model from specified property and hierarchy definitions. There are two types of custom composite models, <code>inline</code> and <code>component-model-based</code>. </p> <p>Use component-model-based custom composite models to define standard, reusable components. A component-model-based custom composite model consists of a name, a description, and the ID of the component model it references. A component-model-based custom composite model has no properties of its own; its referenced component model provides its associated properties to any created assets. For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/custom-composite-models.html">Custom composite models (Components)</a> in the <i>IoT SiteWise User Guide</i>.</p> <p>Use inline custom composite models to organize the properties of an asset model. The properties of inline custom composite models are local to the asset model where they are included and can't be used to create multiple assets.</p> <p>To create a component-model-based model, specify the <code>composedAssetModelId</code> of an existing asset model with <code>assetModelType</code> of <code>COMPONENT_MODEL</code>.</p> <p>To create an inline model, specify the <code>assetModelCompositeModelProperties</code> and don't include an <code>composedAssetModelId</code>.</p>

    Args:
        asset_model_id: <p>The ID of the asset model this composite model is a part of.</p>
        asset_model_composite_model_external_id: <p>An external ID to assign to the composite model.</p> <p>If the composite model is a derived composite model, or one nested inside a component model, you can only set the external ID using <code>UpdateAssetModelCompositeModel</code> and specifying the derived ID of the model or property from the created model it's a part of.</p>
        parent_asset_model_composite_model_id: <p>The ID of the parent composite model in this asset model relationship.</p>
        asset_model_composite_model_id: <p>The ID of the composite model. 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_model_composite_model_description: <p>A description for the composite model.</p>
        asset_model_composite_model_name: <p>A unique name for the composite model.</p>
        asset_model_composite_model_type: <p>The composite model type. Valid values are <code>AWS/ALARM</code>, <code>CUSTOM</code>, or <code> AWS/L4E_ANOMALY</code>.</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>
        composed_asset_model_id: <p>The ID of a component model which is reused to create this composite model.</p>
        asset_model_composite_model_properties: <p>The property definitions of the composite model. For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/custom-composite-models.html#inline-composite-models"> Inline custom composite models</a> in the <i>IoT SiteWise User Guide</i>.</p> <p>You can specify up to 200 properties per composite model. 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>
        if_match: <p>The expected current entity tag (ETag) for the asset model’s latest or active version (specified using <code>matchForVersionType</code>). The create request is rejected if the tag does not match the latest or active version's current entity tag. See <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/opt-locking-for-model.html">Optimistic locking for asset model writes</a> in the <i>IoT SiteWise User Guide</i>.</p>
        if_none_match: <p>Accepts <b>*</b> to reject the create request if an active version (specified using <code>matchForVersionType</code> as <code>ACTIVE</code>) already exists for the asset model.</p>
        match_for_version_type: <p>Specifies the asset model version type (<code>LATEST</code> or <code>ACTIVE</code>) used in conjunction with <code>If-Match</code> or <code>If-None-Match</code> headers to determine the target ETag for the create operation.</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.precondition_failed_exception.PreconditionFailedException: <p>The precondition in one or more of the request-header fields evaluated to <code>FALSE</code>.</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_model_composite_model_request.CreateAssetModelCompositeModelRequest]",
    ) -> OperationResponse[
        "capo_iotsitewise.types.create_asset_model_composite_model_response.CreateAssetModelCompositeModelResponse"
    ]:
        import capo_iotsitewise._operations.aws_io_t_site_wise.create_asset_model_composite_model

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAssetModelCompositeModel")
    )
    input_: capo_iotsitewise.types.create_asset_model_composite_model_request.CreateAssetModelCompositeModelRequest = {
        "asset_model_id": asset_model_id,
        "asset_model_composite_model_name": asset_model_composite_model_name,
        "asset_model_composite_model_type": asset_model_composite_model_type,
    }
    if asset_model_composite_model_external_id is not None:
        input_["asset_model_composite_model_external_id"] = (
            asset_model_composite_model_external_id
        )
    if parent_asset_model_composite_model_id is not None:
        input_["parent_asset_model_composite_model_id"] = (
            parent_asset_model_composite_model_id
        )
    if asset_model_composite_model_id is not None:
        input_["asset_model_composite_model_id"] = asset_model_composite_model_id
    if asset_model_composite_model_description is not None:
        input_["asset_model_composite_model_description"] = (
            asset_model_composite_model_description
        )
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if composed_asset_model_id is not None:
        input_["composed_asset_model_id"] = composed_asset_model_id
    if asset_model_composite_model_properties is not None:
        input_["asset_model_composite_model_properties"] = (
            asset_model_composite_model_properties
        )
    if if_match is not None:
        input_["if_match"] = if_match
    if if_none_match is not None:
        input_["if_none_match"] = if_none_match
    if match_for_version_type is not None:
        input_["match_for_version_type"] = match_for_version_type

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