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

hub.exec.boto3.client.appconfig.create_configuration_profile
hub.exec.boto3.client.appconfig.delete_configuration_profile
hub.exec.boto3.client.appconfig.get_configuration_profile
hub.exec.boto3.client.appconfig.list_configuration_profiles
hub.exec.boto3.client.appconfig.update_configuration_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, application_id: Text, location_uri: Text, description: Text = None, retrieval_role_arn: Text = None, validators: List = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Information that enables AppConfig to access the configuration source. Valid configuration sources include
    Systems Manager (SSM) documents, SSM Parameter Store parameters, and Amazon S3 objects. A configuration profile
    includes the following information.   The Uri location of the configuration data.   The AWS Identity and Access
    Management (IAM) role that provides access to the configuration data.   A validator for the configuration data.
    Available validators include either a JSON Schema or an AWS Lambda function.   For more information, see Create
    a Configuration and a Configuration Profile in the AWS AppConfig User Guide.

    Args:
        name(Text): A name for the configuration profile.
        application_id(Text): The application ID.
        description(Text, optional): A description of the configuration profile. Defaults to None.
        location_uri(Text): A URI to locate the configuration. You can specify a Systems Manager (SSM) document, an SSM
            Parameter Store parameter, or an Amazon S3 object. For an SSM document, specify either the
            document name in the format ssm-document://<Document_name> or the Amazon Resource Name (ARN).
            For a parameter, specify either the parameter name in the format ssm-
            parameter://<Parameter_name> or the ARN. For an Amazon S3 object, specify the URI in the
            following format: s3://<bucket>/<objectKey> . Here is an example: s3://my-bucket/my-app/us-
            east-1/my-config.json.
        retrieval_role_arn(Text, optional): The ARN of an IAM role with permission to access the configuration at the specified LocationUri. Defaults to None.
        validators(List, optional): A list of methods for validating the configuration. Defaults to None.
        tags(Dict, optional): Metadata to assign to the configuration profile. Tags help organize and categorize your
            AppConfig resources. Each tag consists of a key and an optional value, both of which you define. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.appconfig.create_configuration_profile(
                ctx,
                
                
                **{"Name": name, "ApplicationId": application_id, "Description": description, "LocationUri": location_uri, "RetrievalRoleArn": retrieval_role_arn, "Validators": validators, "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.appconfig.get_configuration_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, application_id: Text, configuration_profile_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete a configuration profile. Deleting a configuration profile does not delete a configuration from a host.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        application_id(Text): The application ID that includes the configuration profile you want to delete.
        configuration_profile_id(Text): The ID of the configuration profile you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.appconfig.configuration_profile.absent:
                - name: value
                - application_id: value
                - configuration_profile_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.appconfig.configuration_profile.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.appconfig.get_configuration_profile(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.appconfig.delete_configuration_profile(
                ctx,
                
                
                **{"ApplicationId": application_id, "ConfigurationProfileId": configuration_profile_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.appconfig.get_configuration_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

