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

hub.exec.boto3.client.chime.create_app_instance_admin
hub.exec.boto3.client.chime.delete_app_instance_admin
hub.exec.boto3.client.chime.describe_app_instance_admin
hub.exec.boto3.client.chime.list_app_instance_admins
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, app_instance_admin_arn: Text, app_instance_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Promotes an AppInstanceUser to an AppInstanceAdmin. The promoted user can perform the following actions.
    ChannelModerator actions across all channels in the AppInstance.    DeleteChannelMessage actions.   Only an
    AppInstanceUser can be promoted to an AppInstanceAdmin role.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        app_instance_admin_arn(Text): The ARN of the administrator of the current AppInstance.
        app_instance_arn(Text): The ARN of the AppInstance.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.chime.app_instance_admin.present:
                - name: value
                - app_instance_admin_arn: value
                - app_instance_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.chime.app_instance_admin.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.chime.describe_app_instance_admin(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.create_app_instance_admin(
                ctx,
                
                
                **{"AppInstanceAdminArn": app_instance_admin_arn, "AppInstanceArn": app_instance_arn}
            )
            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.chime.describe_app_instance_admin(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, app_instance_admin_arn: Text, app_instance_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Demotes an AppInstanceAdmin to an AppInstanceUser. This action does not delete the user.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        app_instance_admin_arn(Text): The ARN of the AppInstance's administrator.
        app_instance_arn(Text): The ARN of the AppInstance.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.chime.app_instance_admin.absent:
                - name: value
                - app_instance_admin_arn: value
                - app_instance_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.chime.app_instance_admin.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.chime.describe_app_instance_admin(name)

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

