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

hub.exec.boto3.client.imagebuilder.create_container_recipe
hub.exec.boto3.client.imagebuilder.delete_container_recipe
hub.exec.boto3.client.imagebuilder.get_container_recipe
hub.exec.boto3.client.imagebuilder.list_container_recipes
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, container_type: Text, semantic_version: Text, components: List, parent_image: Text, target_repository: Dict, client_token: Text, description: Text = None, instance_configuration: Dict = None, dockerfile_template_data: Text = None, dockerfile_template_uri: Text = None, platform_override: Text = None, image_os_version_override: Text = None, tags: Dict = None, working_directory: Text = None, kms_key_id: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new container recipe. Container recipes define how images are configured, tested, and assessed.

    Args:
        name(Text): The name of the container recipe.
        container_type(Text): The type of container to create.
        description(Text, optional): The description of the container recipe. Defaults to None.
        semantic_version(Text): The semantic version of the container recipe. This version follows the semantic version syntax.
            The semantic version has four nodes: <major>.<minor>.<patch>/<build>. You can assign values for
            the first three, and can filter on all of them.  Assignment: For the first three nodes you can
            assign any positive integer value, including zero, with an upper limit of 2^30-1, or 1073741823
            for each node. Image Builder automatically assigns the build number, and that is not open for
            updates.  Patterns: You can use any numeric pattern that adheres to the assignment requirements
            for the nodes that you can assign. For example, you might choose a software version pattern,
            such as 1.0.0, or a date, such as 2021.01.01.
        components(List): Components for build and test that are included in the container recipe.
        instance_configuration(Dict, optional): A group of options that can be used to configure an instance for building and testing container
            images. Defaults to None.
        dockerfile_template_data(Text, optional): The Dockerfile template used to build your image as an inline data blob. Defaults to None.
        dockerfile_template_uri(Text, optional): The Amazon S3 URI for the Dockerfile that will be used to build your container image. Defaults to None.
        platform_override(Text, optional): Specifies the operating system platform when you use a custom source image. Defaults to None.
        image_os_version_override(Text, optional): Specifies the operating system version for the source image. Defaults to None.
        parent_image(Text): The source image for the container recipe.
        tags(Dict, optional): Tags that are attached to the container recipe. Defaults to None.
        working_directory(Text, optional): The working directory for use during build and test workflows. Defaults to None.
        target_repository(Dict): The destination repository for the container image.
        kms_key_id(Text, optional): Identifies which KMS key is used to encrypt the container image. Defaults to None.
        client_token(Text): The client token used to make this request idempotent.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.imagebuilder.container_recipe.present:
                - name: value
                - container_type: value
                - semantic_version: value
                - components: value
                - parent_image: value
                - target_repository: value
                - client_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.imagebuilder.container_recipe.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_container_recipe(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.imagebuilder.create_container_recipe(
                ctx,
                
                
                **{"Name": name, "containerType": container_type, "description": description, "semanticVersion": semantic_version, "components": components, "instanceConfiguration": instance_configuration, "dockerfileTemplateData": dockerfile_template_data, "dockerfileTemplateUri": dockerfile_template_uri, "platformOverride": platform_override, "imageOsVersionOverride": image_os_version_override, "parentImage": parent_image, "tags": tags, "workingDirectory": working_directory, "targetRepository": target_repository, "kmsKeyId": kms_key_id, "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_container_recipe(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

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

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

