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

hub.exec.boto3.client.wellarchitected.create_workload
hub.exec.boto3.client.wellarchitected.delete_workload
hub.exec.boto3.client.wellarchitected.get_workload
hub.exec.boto3.client.wellarchitected.list_workloads
hub.exec.boto3.client.wellarchitected.update_workload
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, workload_name: Text, description: Text, environment: Text, review_owner: Text, lenses: List, client_request_token: Text, account_ids: List = None, aws_regions: List = None, non_aws_regions: List = None, pillar_priorities: List = None, architectural_design: Text = None, industry_type: Text = None, industry: Text = None, notes: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a new workload. The owner of a workload can share the workload with other AWS accounts and IAM users in
    the same AWS Region. Only the owner of a workload can delete it. For more information, see Defining a Workload
    in the AWS Well-Architected Tool User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        workload_name(Text): The name of the workload. The name must be unique within an account within a Region. Spaces and
            capitalization are ignored when checking for uniqueness.
        description(Text): The description for the workload.
        environment(Text): The environment for the workload.
        account_ids(List, optional): The list of AWS account IDs associated with the workload. Defaults to None.
        aws_regions(List, optional): The list of AWS Regions associated with the workload, for example, us-east-2, or ca-central-1. Defaults to None.
        non_aws_regions(List, optional):  The list of non-AWS Regions associated with the workload. Defaults to None.
        pillar_priorities(List, optional): The priorities of the pillars, which are used to order items in the improvement plan. Each
            pillar is represented by its PillarReviewSummary$PillarId. Defaults to None.
        architectural_design(Text, optional): The URL of the architectural design for the workload. Defaults to None.
        review_owner(Text): The review owner of the workload. The name, email address, or identifier for the primary group
            or individual that owns the workload review process.
        industry_type(Text, optional): The industry type for the workload. If specified, must be one of the following:    Agriculture
            Automobile     Defense     Design and Engineering     Digital Advertising     Education
            Environmental Protection     Financial Services     Gaming     General Public Services
            Healthcare     Hospitality     InfoTech     Justice and Public Safety     Life Sciences
            Manufacturing     Media & Entertainment     Mining & Resources     Oil & Gas     Power &
            Utilities     Professional Services     Real Estate & Construction     Retail & Wholesale
            Social Protection     Telecommunications     Travel, Transportation & Logistics     Other. Defaults to None.
        industry(Text, optional): The industry for the workload. Defaults to None.
        lenses(List): The list of lenses associated with the workload. Each lens is identified by its
            LensSummary$LensAlias.
        notes(Text, optional): The notes associated with the workload. Defaults to None.
        client_request_token(Text): A unique case-sensitive string used to ensure that this request is idempotent (executes only
            once). You should not reuse the same token for other requests. If you retry a request with the
            same client request token and the same parameters after it has completed successfully, the
            result of the original request is returned.   This token is listed as required, however, if you
            do not specify it, the AWS SDKs automatically generate one for you. If you are not using the AWS
            SDK or the AWS CLI, you must provide this token or the request will fail.
        tags(Dict, optional): The tags to be associated with the workload. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.wellarchitected.workload.present:
                - name: value
                - workload_name: value
                - description: value
                - environment: value
                - review_owner: value
                - lenses: value
                - client_request_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.wellarchitected.workload.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.wellarchitected.get_workload(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.wellarchitected.create_workload(
                ctx,
                
                
                **{"WorkloadName": workload_name, "Description": description, "Environment": environment, "AccountIds": account_ids, "AwsRegions": aws_regions, "NonAwsRegions": non_aws_regions, "PillarPriorities": pillar_priorities, "ArchitecturalDesign": architectural_design, "ReviewOwner": review_owner, "IndustryType": industry_type, "Industry": industry, "Lenses": lenses, "Notes": notes, "ClientRequestToken": client_request_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.wellarchitected.get_workload(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, workload_id: Text, client_request_token: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete an existing workload.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        workload_id(Text): The ID assigned to the workload. This ID is unique within an AWS Region.
        client_request_token(Text): A unique case-sensitive string used to ensure that this request is idempotent (executes only
            once). You should not reuse the same token for other requests. If you retry a request with the
            same client request token and the same parameters after it has completed successfully, the
            result of the original request is returned.   This token is listed as required, however, if you
            do not specify it, the AWS SDKs automatically generate one for you. If you are not using the AWS
            SDK or the AWS CLI, you must provide this token or the request will fail.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.wellarchitected.workload.absent:
                - name: value
                - workload_id: value
                - client_request_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.wellarchitected.workload.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.wellarchitected.get_workload(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.wellarchitected.delete_workload(
                ctx,
                
                
                **{"WorkloadId": workload_id, "ClientRequestToken": client_request_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.wellarchitected.get_workload(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

