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

hub.exec.boto3.client.iot.create_domain_configuration
hub.exec.boto3.client.iot.delete_domain_configuration
hub.exec.boto3.client.iot.describe_domain_configuration
hub.exec.boto3.client.iot.list_domain_configurations
hub.exec.boto3.client.iot.update_domain_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, domain_configuration_name: Text, domain_name: Text = None, server_certificate_arns: List = None, validation_certificate_arn: Text = None, authorizer_config: Dict = None, service_type: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a domain configuration.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_configuration_name(Text): The name of the domain configuration. This value must be unique to a region.
        domain_name(Text, optional): The name of the domain. Defaults to None.
        server_certificate_arns(List, optional): The ARNs of the certificates that AWS IoT passes to the device during the TLS handshake.
            Currently you can specify only one certificate ARN. This value is not required for AWS-managed
            domains. Defaults to None.
        validation_certificate_arn(Text, optional): The certificate used to validate the server certificate and prove domain name ownership. This
            certificate must be signed by a public certificate authority. This value is not required for
            AWS-managed domains. Defaults to None.
        authorizer_config(Dict, optional): An object that specifies the authorization service for a domain. Defaults to None.
        service_type(Text, optional): The type of service delivered by the endpoint.  AWS IoT Core currently supports only the DATA
            service type. Defaults to None.
        tags(List, optional): Metadata which can be used to manage the domain configuration.  For URI Request parameters use
            format: ...key1=value1&key2=value2... For the CLI command-line parameter use format: &&tags
            "key1=value1&key2=value2..." For the cli-input-json file use format: "tags":
            "key1=value1&key2=value2...". Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.iot.create_domain_configuration(
                ctx,
                
                
                **{"domainConfigurationName": domain_configuration_name, "domainName": domain_name, "serverCertificateArns": server_certificate_arns, "validationCertificateArn": validation_certificate_arn, "authorizerConfig": authorizer_config, "serviceType": service_type, "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.iot.describe_domain_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, domain_configuration_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified domain configuration.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_configuration_name(Text): The name of the domain configuration to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

