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

hub.exec.boto3.client.fsx.associate_file_system_aliases
hub.exec.boto3.client.fsx.describe_file_system_aliases
hub.exec.boto3.client.fsx.disassociate_file_system_aliases
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, file_system_id: Text, aliases: List, client_request_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Use this action to associate one or more Domain Name Server (DNS) aliases with an existing Amazon FSx for
    Windows File Server file system. A file systen can have a maximum of 50 DNS aliases associated with it at any
    one time. If you try to associate a DNS alias that is already associated with the file system, FSx takes no
    action on that alias in the request. For more information, see Working with DNS Aliases and Walkthrough 5: Using
    DNS aliases to access your file system, including additional steps you must take to be able to access your file
    system using a DNS alias. The system response shows the DNS aliases that Amazon FSx is attempting to associate
    with the file system. Use the API operation to monitor the status of the aliases Amazon FSx is associating with
    the file system.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_request_token(Text, optional): (Optional) An idempotency token for resource creation, in a string of up to 64 ASCII characters.
            This token is automatically filled on your behalf when you use the AWS Command Line Interface
            (AWS CLI) or an AWS SDK. Defaults to None.
        file_system_id(Text): Specifies the file system with which you want to associate one or more DNS aliases.
        aliases(List): An array of one or more DNS alias names to associate with the file system. The alias name has to
            comply with the following formatting requirements:   Formatted as a fully-qualified domain name
            (FQDN),  hostname.domain , for example, accounting.corp.example.com.   Can contain alphanumeric
            characters and the hyphen (-).   Cannot start or end with a hyphen.   Can start with a numeric.
            For DNS alias names, Amazon FSx stores alphabetic characters as lowercase letters (a-z),
            regardless of how you specify them: as uppercase letters, lowercase letters, or the
            corresponding letters in escape codes.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.fsx.associate_file_system_aliases(
                ctx,
                
                
                **{"ClientRequestToken": client_request_token, "FileSystemId": file_system_id, "Aliases": aliases}
            )
            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.fsx.describe_file_system_aliases(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, file_system_id: Text, aliases: List, client_request_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Use this action to disassociate, or remove, one or more Domain Name Service (DNS) aliases from an Amazon FSx for
    Windows File Server file system. If you attempt to disassociate a DNS alias that is not associated with the file
    system, Amazon FSx responds with a 400 Bad Request. For more information, see Working with DNS Aliases. The
    system generated response showing the DNS aliases that Amazon FSx is attempting to disassociate from the file
    system. Use the API operation to monitor the status of the aliases Amazon FSx is disassociating with the file
    system.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_request_token(Text, optional): (Optional) An idempotency token for resource creation, in a string of up to 64 ASCII characters.
            This token is automatically filled on your behalf when you use the AWS Command Line Interface
            (AWS CLI) or an AWS SDK. Defaults to None.
        file_system_id(Text): Specifies the file system from which to disassociate the DNS aliases.
        aliases(List): An array of one or more DNS alias names to disassociate, or remove, from the file system.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.fsx.file_system_aliase.absent:
                - name: value
                - file_system_id: value
                - aliases: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.fsx.file_system_aliase.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.fsx.describe_file_system_aliases(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.fsx.disassociate_file_system_aliases(
                ctx,
                
                
                **{"ClientRequestToken": client_request_token, "FileSystemId": file_system_id, "Aliases": aliases}
            )
            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.fsx.describe_file_system_aliases(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

