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

hub.exec.boto3.client.appconfig.create_hosted_configuration_version
hub.exec.boto3.client.appconfig.delete_hosted_configuration_version
hub.exec.boto3.client.appconfig.get_hosted_configuration_version
hub.exec.boto3.client.appconfig.list_hosted_configuration_versions
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, application_id: Text, configuration_profile_id: Text, content: ByteString, content_type: Text, description: Text = None, latest_version_number: int = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a new configuration in the AppConfig configuration store.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        application_id(Text): The application ID.
        configuration_profile_id(Text): The configuration profile ID.
        description(Text, optional): A description of the configuration. Defaults to None.
        content(ByteString): The content of the configuration or the configuration data.
        content_type(Text): A standard MIME type describing the format of the configuration content. For more information,
            see Content-Type.
        latest_version_number(int, optional): An optional locking token used to prevent race conditions from overwriting configuration updates
            when creating a new version. To ensure your data is not overwritten when creating multiple
            hosted configuration versions in rapid succession, specify the version of the latest hosted
            configuration version. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.appconfig.create_hosted_configuration_version(
                ctx,
                
                
                **{"ApplicationId": application_id, "ConfigurationProfileId": configuration_profile_id, "Description": description, "Content": content, "ContentType": content_type, "LatestVersionNumber": latest_version_number}
            )
            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_hosted_configuration_version(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, application_id: Text, configuration_profile_id: Text, version_number: int)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete a version of a configuration from the AppConfig configuration store.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        application_id(Text): The application ID.
        configuration_profile_id(Text): The configuration profile ID.
        version_number(int): The versions number to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

