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

hub.exec.boto3.client.glue.create_registry
hub.exec.boto3.client.glue.delete_registry
hub.exec.boto3.client.glue.get_registry
hub.exec.boto3.client.glue.list_registries
hub.exec.boto3.client.glue.update_registry
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, registry_name: Text, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new registry which may be used to hold a collection of schemas.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        registry_name(Text): Name of the registry to be created of max length of 255, and may only contain letters, numbers,
            hyphen, underscore, dollar sign, or hash mark. No whitespace.
        description(Text, optional): A description of the registry. If description is not provided, there will not be any default
            value for this. Defaults to None.
        tags(Dict, optional): Amazon Web Services tags that contain a key value pair and may be searched by console, command
            line, or API. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.glue.create_registry(
                ctx,
                
                
                **{"RegistryName": registry_name, "Description": description, "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.glue.get_registry(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, registry_id: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete the entire registry including schema and all of its versions. To get the status of the delete operation,
    you can call the GetRegistry API after the asynchronous call. Deleting a registry will deactivate all online
    operations for the registry such as the UpdateRegistry, CreateSchema, UpdateSchema, and RegisterSchemaVersion
    APIs.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        registry_id(Dict): This is a wrapper structure that may contain the registry name and Amazon Resource Name (ARN).

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

