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

hub.exec.boto3.client.snowball.cancel_cluster
hub.exec.boto3.client.snowball.create_cluster
hub.exec.boto3.client.snowball.describe_cluster
hub.exec.boto3.client.snowball.list_clusters
hub.exec.boto3.client.snowball.update_cluster
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, job_type: Text, resources: Dict, address_id: Text, role_arn: Text, snowball_type: Text, shipping_option: Text, on_device_service_configuration: Dict = None, description: Text = None, kms_key_arn: Text = None, notification: Dict = None, forwarding_address_id: Text = None, tax_documents: Dict = None, remote_management: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an empty cluster. Each cluster supports five nodes. You use the CreateJob action separately to create
    the jobs for each of these nodes. The cluster does not ship until these five node jobs have been created.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        job_type(Text): The type of job for this cluster. Currently, the only job type supported for clusters is
            LOCAL_USE. For more information, see "https://docs.aws.amazon.com/snowball/latest/snowcone-
            guide/snow-device-types.html" (Snow Family Devices and Capacity) in the Snowcone User Guide or
            "https://docs.aws.amazon.com/snowball/latest/developer-guide/snow-device-types.html" (Snow
            Family Devices and Capacity) in the Snowcone User Guide.
        resources(Dict): The resources associated with the cluster job. These resources include Amazon S3 buckets and
            optional AWS Lambda functions written in the Python language.
        on_device_service_configuration(Dict, optional): Specifies the service or services on the Snow Family device that your transferred data will be
            exported from or imported into. AWS Snow Family supports Amazon S3 and NFS (Network File
            System). Defaults to None.
        description(Text, optional): An optional description of this specific cluster, for example Environmental Data Cluster-01. Defaults to None.
        address_id(Text): The ID for the address that you want the cluster shipped to.
        kms_key_arn(Text, optional): The KmsKeyARN value that you want to associate with this cluster. KmsKeyARN values are created
            by using the CreateKey API action in AWS Key Management Service (AWS KMS). Defaults to None.
        role_arn(Text): The RoleARN that you want to associate with this cluster. RoleArn values are created by using
            the CreateRole API action in AWS Identity and Access Management (IAM).
        snowball_type(Text): The type of AWS Snow Family device to use for this cluster.   For cluster jobs, AWS Snow Family
            currently supports only the EDGE device type.  For more information, see
            "https://docs.aws.amazon.com/snowball/latest/snowcone-guide/snow-device-types.html" (Snow Family
            Devices and Capacity) in the Snowcone User Guide or
            "https://docs.aws.amazon.com/snowball/latest/developer-guide/snow-device-types.html" (Snow
            Family Devices and Capacity) in the Snowcone User Guide.
        shipping_option(Text): The shipping speed for each node in this cluster. This speed doesn't dictate how soon you'll get
            each Snowball Edge device, rather it represents how quickly each device moves to its destination
            while in transit. Regional shipping speeds are as follows:    In Australia, you have access to
            express shipping. Typically, Snow devices shipped express are delivered in about a day.   In the
            European Union (EU), you have access to express shipping. Typically, Snow devices shipped
            express are delivered in about a day. In addition, most countries in the EU have access to
            standard shipping, which typically takes less than a week, one way.   In India, Snow devices are
            delivered in one to seven days.   In the United States of America (US), you have access to one-
            day shipping and two-day shipping.     In Australia, you have access to express shipping.
            Typically, devices shipped express are delivered in about a day.   In the European Union (EU),
            you have access to express shipping. Typically, Snow devices shipped express are delivered in
            about a day. In addition, most countries in the EU have access to standard shipping, which
            typically takes less than a week, one way.   In India, Snow devices are delivered in one to
            seven days.   In the US, you have access to one-day shipping and two-day shipping.
        notification(Dict, optional): The Amazon Simple Notification Service (Amazon SNS) notification settings for this cluster. Defaults to None.
        forwarding_address_id(Text, optional): The forwarding address ID for a cluster. This field is not supported in most regions. Defaults to None.
        tax_documents(Dict, optional): The tax documents required in your AWS Region. Defaults to None.
        remote_management(Text, optional): Allows you to securely operate and manage Snow devices in a cluster remotely from outside of
            your internal network. When set to INSTALLED_AUTOSTART, remote management will automatically be
            available when the device arrives at your location. Otherwise, you need to use the Snowball
            Client to manage the device. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.snowball.cluster.present:
                - name: value
                - job_type: value
                - resources: value
                - address_id: value
                - role_arn: value
                - snowball_type: value
                - shipping_option: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.snowball.cluster.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.snowball.describe_cluster(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.snowball.create_cluster(
                ctx,
                
                
                **{"JobType": job_type, "Resources": resources, "OnDeviceServiceConfiguration": on_device_service_configuration, "Description": description, "AddressId": address_id, "KmsKeyARN": kms_key_arn, "RoleARN": role_arn, "SnowballType": snowball_type, "ShippingOption": shipping_option, "Notification": notification, "ForwardingAddressId": forwarding_address_id, "TaxDocuments": tax_documents, "RemoteManagement": remote_management}
            )
            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.snowball.describe_cluster(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, cluster_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Cancels a cluster job. You can only cancel a cluster job while it's in the AwaitingQuorum status. You'll have at
    least an hour after creating a cluster job to cancel it.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cluster_id(Text): The 39-character ID for the cluster that you want to cancel, for example
            CID123e4567-e89b-12d3-a456-426655440000.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.snowball.cluster.absent:
                - name: value
                - cluster_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.snowball.cluster.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.snowball.describe_cluster(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.snowball.cancel_cluster(
                ctx,
                
                
                **{"ClusterId": cluster_id}
            )
            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.snowball.describe_cluster(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

