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

hub.exec.boto3.client.devicefarm.create_instance_profile
hub.exec.boto3.client.devicefarm.delete_instance_profile
hub.exec.boto3.client.devicefarm.get_instance_profile
hub.exec.boto3.client.devicefarm.list_instance_profiles
hub.exec.boto3.client.devicefarm.update_instance_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, description: Text = None, package_cleanup: bool = None, exclude_app_packages_from_cleanup: List = None, reboot_after_use: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a profile that can be applied to one or more private fleet device instances.

    Args:
        name(Text): The name of your instance profile.
        description(Text, optional): The description of your instance profile. Defaults to None.
        package_cleanup(bool, optional): When set to true, Device Farm removes app packages after a test run. The default value is false
            for private devices. Defaults to None.
        exclude_app_packages_from_cleanup(List, optional): An array of strings that specifies the list of app packages that should not be cleaned up from
            the device after a test run. The list of packages is considered only if you set packageCleanup
            to true. Defaults to None.
        reboot_after_use(bool, optional): When set to true, Device Farm reboots the instance after a test run. The default value is true. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.devicefarm.instance_profile.present:
                - name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.devicefarm.instance_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.devicefarm.get_instance_profile(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.devicefarm.create_instance_profile(
                ctx,
                
                
                **{"Name": name, "description": description, "packageCleanup": package_cleanup, "excludeAppPackagesFromCleanup": exclude_app_packages_from_cleanup, "rebootAfterUse": reboot_after_use}
            )
            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.devicefarm.get_instance_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a profile that can be applied to one or more private device instances.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        arn(Text): The Amazon Resource Name (ARN) of the instance profile you are requesting to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.devicefarm.instance_profile.absent:
                - name: value
                - arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.devicefarm.instance_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.devicefarm.get_instance_profile(name)

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

