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

hub.exec.boto3.client.chime.create_account
hub.exec.boto3.client.chime.delete_account
hub.exec.boto3.client.chime.get_account
hub.exec.boto3.client.chime.list_accounts
hub.exec.boto3.client.chime.update_account
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an Amazon Chime account under the administrator's AWS account. Only Team account types are currently
    supported for this action. For more information about different account types, see Managing Your Amazon Chime
    Accounts in the Amazon Chime Administration Guide.

    Args:
        name(Text): The name of the Amazon Chime account.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, account_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified Amazon Chime account. You must suspend all users before deleting Team account. You can use
    the BatchSuspendUser action to dodo. For EnterpriseLWA and EnterpriseAD accounts, you must release the claimed
    domains for your Amazon Chime account before deletion. As soon as you release the domain, all users under that
    account are suspended. Deleted accounts appear in your Disabled accounts list for 90 days. To restore deleted
    account from your Disabled accounts list, you must contact AWS Support. After 90 days, deleted accounts are
    permanently removed from your Disabled accounts list.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        account_id(Text): The Amazon Chime account ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

