"""
Autogenerated state module using `pop-create-idem <https://gitlab.com/saltstack/pop/pop-create-idem>`__

hub.exec.boto3.client.iotsitewise.create_asset_model
hub.exec.boto3.client.iotsitewise.delete_asset_model
hub.exec.boto3.client.iotsitewise.describe_asset_model
hub.exec.boto3.client.iotsitewise.list_asset_models
hub.exec.boto3.client.iotsitewise.update_asset_model
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, asset_model_name: Text, asset_model_description: Text = None, asset_model_properties: List = None, asset_model_hierarchies: List = None, asset_model_composite_models: List = None, client_token: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates 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 IoT SiteWise User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        asset_model_name(Text): A unique, friendly name for the asset model.
        asset_model_description(Text, optional): A description for the asset model. Defaults to None.
        asset_model_properties(List, optional): The property definitions of the asset model. For more information, see Asset properties in the
            IoT SiteWise User Guide. You can specify up to 200 properties per asset model. For more
            information, see Quotas in the IoT SiteWise User Guide. Defaults to None.
        asset_model_hierarchies(List, optional): The hierarchy definitions of the asset model. Each hierarchy specifies an asset model whose
            assets can be children of any other assets created from this asset model. For more information,
            see Asset hierarchies in the IoT SiteWise User Guide. You can specify up to 10 hierarchies per
            asset model. For more information, see Quotas in the IoT SiteWise User Guide. Defaults to None.
        asset_model_composite_models(List, optional): The composite asset models that are part of this asset model. Composite asset models are asset
            models that contain specific properties. Each composite model has a type that defines the
            properties that the composite model supports. Use composite asset models to define alarms on
            this asset model. Defaults to None.
        client_token(Text, optional): 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. Defaults to None.
        tags(Dict, optional): A list of key-value pairs that contain metadata for the asset model. For more information, see
            Tagging your IoT SiteWise resources in the IoT SiteWise User Guide. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.iotsitewise.asset_model.present:
                - name: value
                - asset_model_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.iotsitewise.asset_model.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    
    before = await hub.exec.boto3.client.iotsitewise.describe_asset_model(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.iotsitewise.create_asset_model(
                ctx,
                
                
                **{"assetModelName": asset_model_name, "assetModelDescription": asset_model_description, "assetModelProperties": asset_model_properties, "assetModelHierarchies": asset_model_hierarchies, "assetModelCompositeModels": asset_model_composite_models, "clientToken": client_token, "tags": tags}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            ret["comment"] = f"Created '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    
    # TODO perform other modifications as needed here
    ...

    after = await hub.exec.boto3.client.iotsitewise.describe_asset_model(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, asset_model_id: Text, client_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes 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 IoT SiteWise User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        asset_model_id(Text): The ID of the asset model to delete.
        client_token(Text, optional): 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. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.iotsitewise.asset_model.absent:
                - name: value
                - asset_model_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.iotsitewise.asset_model.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    

    before = await hub.exec.boto3.client.iotsitewise.describe_asset_model(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.iotsitewise.delete_asset_model(
                ctx,
                
                
                **{"assetModelId": asset_model_id, "clientToken": client_token}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            result["comment"] = f"Deleted '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    

    after = await hub.exec.boto3.client.iotsitewise.describe_asset_model(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

