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

hub.exec.boto3.client.codestar_connections.create_host
hub.exec.boto3.client.codestar_connections.delete_host
hub.exec.boto3.client.codestar_connections.get_host
hub.exec.boto3.client.codestar_connections.list_hosts
hub.exec.boto3.client.codestar_connections.update_host
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, provider_type: Text, provider_endpoint: Text, vpc_configuration: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a resource that represents the infrastructure where a third-party provider is installed. The host is
    used when you create connections to an installed third-party provider type, such as GitHub Enterprise Server.
    You create one host for all connections to that provider.  A host created through the CLI or the SDK is in
    `PENDING` status by default. You can make its status `AVAILABLE` by setting up the host in the console.

    Args:
        name(Text): The name of the host to be created. The name must be unique in the calling AWS account.
        provider_type(Text): The name of the installed provider to be associated with your connection. The host resource
            represents the infrastructure where your provider type is installed. The valid provider type is
            GitHub Enterprise Server.
        provider_endpoint(Text): The endpoint of the infrastructure to be represented by the host after it is created.
        vpc_configuration(Dict, optional): The VPC configuration to be provisioned for the host. A VPC must be configured and the
            infrastructure to be represented by the host must already be connected to the VPC. Defaults to None.
        tags(List, optional): . Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.codestar_connections.create_host(
                ctx,
                
                
                **{"Name": name, "ProviderType": provider_type, "ProviderEndpoint": provider_endpoint, "VpcConfiguration": vpc_configuration, "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.codestar_connections.get_host(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, host_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    The host to be deleted. Before you delete a host, all connections associated to the host must be deleted.  A
    host cannot be deleted if it is in the VPC_CONFIG_INITIALIZING or VPC_CONFIG_DELETING state.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        host_arn(Text): The Amazon Resource Name (ARN) of the host to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

