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

hub.exec.boto3.client.gamelift.create_alias
hub.exec.boto3.client.gamelift.delete_alias
hub.exec.boto3.client.gamelift.describe_alias
hub.exec.boto3.client.gamelift.list_aliases
hub.exec.boto3.client.gamelift.resolve_alias
hub.exec.boto3.client.gamelift.update_alias
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, routing_strategy: Dict, description: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an alias for a fleet. In most situations, you can use an alias ID in place of a fleet ID. An alias
    provides a level of abstraction for a fleet that is useful when redirecting player traffic from one fleet to
    another, such as when updating your game build.  Amazon GameLift supports two types of routing strategies for
    aliases: simple and terminal. A simple alias points to an active fleet. A terminal alias is used to display
    messaging or link to a URL instead of routing players to an active fleet. For example, you might use a terminal
    alias when a game version is no longer supported and you want to direct players to an upgrade site.  To create a
    fleet alias, specify an alias name, routing strategy, and optional description. Each simple alias can point to
    only one fleet, but a fleet can have multiple aliases. If successful, a new alias record is returned, including
    an alias ID and an ARN. You can reassign an alias to another fleet by calling UpdateAlias.  Related actions
    CreateAlias | ListAliases | DescribeAlias | UpdateAlias | DeleteAlias | ResolveAlias | All APIs by task

    Args:
        name(Text): A descriptive label that is associated with an alias. Alias names do not need to be unique.
        description(Text, optional): A human-readable description of the alias. Defaults to None.
        routing_strategy(Dict): The routing configuration, including routing type and fleet target, for the alias.
        tags(List, optional): A list of labels to assign to the new alias resource. Tags are developer-defined key-value
            pairs. Tagging AWS resources are useful for resource management, access management and cost
            allocation. For more information, see  Tagging AWS Resources in the AWS General Reference. Once
            the resource is created, you can use TagResource, UntagResource, and ListTagsForResource to add,
            remove, and view tags. The maximum tag limit may be lower than stated. See the AWS General
            Reference for actual tagging limits. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.gamelift.create_alias(
                ctx,
                
                
                **{"Name": name, "Description": description, "RoutingStrategy": routing_strategy, "Tags": tags}
            )
            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.gamelift.describe_alias(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, alias_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an alias. This operation removes all record of the alias. Game clients attempting to access a server
    process using the deleted alias receive an error. To delete an alias, specify the alias ID to be deleted.
    Related actions   CreateAlias | ListAliases | DescribeAlias | UpdateAlias | DeleteAlias | ResolveAlias | All
    APIs by task

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        alias_id(Text): A unique identifier of the alias that you want to delete. You can use either the alias ID or ARN
            value.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

