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

hub.exec.boto3.client.snowball.cancel_job
hub.exec.boto3.client.snowball.create_job
hub.exec.boto3.client.snowball.describe_job
hub.exec.boto3.client.snowball.list_jobs
hub.exec.boto3.client.snowball.update_job
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, job_type: Text = None, resources: Dict = None, on_device_service_configuration: Dict = None, description: Text = None, address_id: Text = None, kms_key_arn: Text = None, role_arn: Text = None, snowball_capacity_preference: Text = None, shipping_option: Text = None, notification: Dict = None, cluster_id: Text = None, snowball_type: Text = None, forwarding_address_id: Text = None, tax_documents: Dict = None, device_configuration: Dict = None, remote_management: Text = None, long_term_pricing_id: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a job to import or export data between Amazon S3 and your on-premises data center. Your AWS account must
    have the right trust policies and permissions in place to create a job for a Snow device. If you're creating a
    job for a node in a cluster, you only need to provide the clusterId value; the other job attributes are
    inherited from the cluster.   Only the Snowball; Edge device type is supported when ordering clustered jobs. The
    device capacity is optional. Availability of device types differ by AWS Region. For more information about
    Region availability, see AWS Regional Services.    AWS Snow Family device types and their capacities.    Snow
    Family device type: SNC1_SSD    Capacity: T14   Description: Snowcone       Snow Family device type: SNC1_HDD
    Capacity: T8   Description: Snowcone       Device type: EDGE_S    Capacity: T98   Description: Snowball Edge
    Storage Optimized for data transfer only       Device type: EDGE_CG    Capacity: T42   Description: Snowball
    Edge Compute Optimized with GPU      Device type: EDGE_C    Capacity: T42   Description: Snowball Edge Compute
    Optimized without GPU      Device type: EDGE    Capacity: T100   Description: Snowball Edge Storage Optimized
    with EC2 Compute      Device type: STANDARD    Capacity: T50   Description: Original Snowball device  This
    device is only available in the Ningxia, Beijing, and Singapore AWS Regions.        Device type: STANDARD
    Capacity: T80   Description: Original Snowball device  This device is only available in the Ningxia, Beijing,
    and Singapore AWS Regions.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        job_type(Text, optional): Defines the type of job that you're creating. Defaults to None.
        resources(Dict, optional): Defines the Amazon S3 buckets associated with this job. With IMPORT jobs, you specify the bucket
            or buckets that your transferred data will be imported into. With EXPORT jobs, you specify the
            bucket or buckets that your transferred data will be exported from. Optionally, you can also
            specify a KeyRange value. If you choose to export a range, you define the length of the range by
            providing either an inclusive BeginMarker value, an inclusive EndMarker value, or both. Ranges
            are UTF-8 binary sorted. Defaults to None.
        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): Defines an optional description of this specific job, for example Important Photos 2016-08-11. Defaults to None.
        address_id(Text, optional): The ID for the address that you want the Snow device shipped to. Defaults to None.
        kms_key_arn(Text, optional): The KmsKeyARN that you want to associate with this job. KmsKeyARNs are created using the
            CreateKey AWS Key Management Service (KMS) API action. Defaults to None.
        role_arn(Text, optional): The RoleARN that you want to associate with this job. RoleArns are created using the CreateRole
            AWS Identity and Access Management (IAM) API action. Defaults to None.
        snowball_capacity_preference(Text, optional): If your job is being created in one of the US regions, you have the option of specifying what
            size Snow device you'd like for this job. In all other regions, Snowballs come with 80 TB in
            storage capacity. 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. Defaults to None.
        shipping_option(Text, optional): The shipping speed for this job. This speed doesn't dictate how soon you'll get the Snow device,
            rather it represents how quickly the Snow 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 US, you have access to one-day shipping and two-day shipping. Defaults to None.
        notification(Dict, optional): Defines the Amazon Simple Notification Service (Amazon SNS) notification settings for this job. Defaults to None.
        cluster_id(Text, optional): The ID of a cluster. If you're creating a job for a node in a cluster, you need to provide only
            this clusterId value. The other job attributes are inherited from the cluster. Defaults to None.
        snowball_type(Text, optional): The type of AWS Snow Family device to use for this job.   For cluster jobs, AWS Snow Family
            currently supports only the EDGE device type.  The type of AWS Snow device to use for this job.
            Currently, the only supported device type for cluster jobs is EDGE. For more information, see
            Snowball Edge Device Options in the Snowball Edge Developer Guide. 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. Defaults to None.
        forwarding_address_id(Text, optional): The forwarding address ID for a job. 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.
        device_configuration(Dict, optional): Defines the device configuration for an AWS Snowcone job. 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. Defaults to None.
        remote_management(Text, optional): Allows you to securely operate and manage Snowcone devices 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.
        long_term_pricing_id(Text, optional): The ID of the long-term pricing type for the device. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.snowball.job.present:
                - name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.snowball.job.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_job(name)

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

async def absent(hub, ctx, name: Text, job_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Cancels the specified job. You can only cancel a job before its JobState value changes to PreparingAppliance.
    Requesting the ListJobs or DescribeJob action returns a job's JobState as part of the response element data
    returned.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

