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

hub.exec.boto3.client.imagebuilder.create_image_pipeline
hub.exec.boto3.client.imagebuilder.delete_image_pipeline
hub.exec.boto3.client.imagebuilder.get_image_pipeline
hub.exec.boto3.client.imagebuilder.list_image_pipelines
hub.exec.boto3.client.imagebuilder.update_image_pipeline
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, infrastructure_configuration_arn: Text, client_token: Text, description: Text = None, image_recipe_arn: Text = None, container_recipe_arn: Text = None, distribution_configuration_arn: Text = None, image_tests_configuration: Dict = None, enhanced_image_metadata_enabled: bool = None, schedule: Dict = None, status: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates a new image pipeline. Image pipelines enable you to automate the creation and distribution of images.

    Args:
        name(Text):  The name of the image pipeline.
        description(Text, optional):  The description of the image pipeline. Defaults to None.
        image_recipe_arn(Text, optional):  The Amazon Resource Name (ARN) of the image recipe that will be used to configure images
            created by this image pipeline. Defaults to None.
        container_recipe_arn(Text, optional): The Amazon Resource Name (ARN) of the container recipe that is used to configure images created
            by this container pipeline. Defaults to None.
        infrastructure_configuration_arn(Text):  The Amazon Resource Name (ARN) of the infrastructure configuration that will be used to build
            images created by this image pipeline.
        distribution_configuration_arn(Text, optional):  The Amazon Resource Name (ARN) of the distribution configuration that will be used to configure
            and distribute images created by this image pipeline. Defaults to None.
        image_tests_configuration(Dict, optional):  The image test configuration of the image pipeline. Defaults to None.
        enhanced_image_metadata_enabled(bool, optional):  Collects additional information about the image being created, including the operating system
            (OS) version and package list. This information is used to enhance the overall experience of
            using EC2 Image Builder. Enabled by default. Defaults to None.
        schedule(Dict, optional):  The schedule of the image pipeline. Defaults to None.
        status(Text, optional):  The status of the image pipeline. Defaults to None.
        tags(Dict, optional):  The tags of the image pipeline. Defaults to None.
        client_token(Text):  The idempotency token used to make this request idempotent.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.imagebuilder.create_image_pipeline(
                ctx,
                
                
                **{"Name": name, "description": description, "imageRecipeArn": image_recipe_arn, "containerRecipeArn": container_recipe_arn, "infrastructureConfigurationArn": infrastructure_configuration_arn, "distributionConfigurationArn": distribution_configuration_arn, "imageTestsConfiguration": image_tests_configuration, "enhancedImageMetadataEnabled": enhanced_image_metadata_enabled, "schedule": schedule, "status": status, "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_image_pipeline(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, image_pipeline_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Deletes an image pipeline.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

