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

hub.exec.boto3.client.imagebuilder.create_distribution_configuration
hub.exec.boto3.client.imagebuilder.delete_distribution_configuration
hub.exec.boto3.client.imagebuilder.get_distribution_configuration
hub.exec.boto3.client.imagebuilder.list_distribution_configurations
hub.exec.boto3.client.imagebuilder.update_distribution_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, distributions: List, client_token: Text, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new distribution configuration. Distribution configurations define and configure the outputs of your
    pipeline.

    Args:
        name(Text):  The name of the distribution configuration.
        description(Text, optional):  The description of the distribution configuration. Defaults to None.
        distributions(List):  The distributions of the distribution configuration.
        tags(Dict, optional):  The tags of the distribution configuration. Defaults to None.
        client_token(Text):  The idempotency token of the distribution configuration.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.imagebuilder.distribution_configuration.present:
                - name: value
                - distributions: value
                - client_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.imagebuilder.distribution_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.imagebuilder.get_distribution_configuration(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.imagebuilder.create_distribution_configuration(
                ctx,
                
                
                **{"Name": name, "description": description, "distributions": distributions, "tags": tags, "clientToken": client_token}
            )
            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.imagebuilder.get_distribution_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, distribution_configuration_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Deletes a distribution configuration.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        distribution_configuration_arn(Text): The Amazon Resource Name (ARN) of the distribution configuration to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.imagebuilder.distribution_configuration.absent:
                - name: value
                - distribution_configuration_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.imagebuilder.distribution_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.imagebuilder.get_distribution_configuration(name)

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

