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

hub.exec.boto3.client.transfer.create_server
hub.exec.boto3.client.transfer.delete_server
hub.exec.boto3.client.transfer.describe_server
hub.exec.boto3.client.transfer.list_servers
hub.exec.boto3.client.transfer.start_server
hub.exec.boto3.client.transfer.stop_server
hub.exec.boto3.client.transfer.update_server
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, certificate: Text = None, domain: Text = None, endpoint_details: Dict = None, endpoint_type: Text = None, host_key: Text = None, identity_provider_details: Dict = None, identity_provider_type: Text = None, logging_role: Text = None, protocols: List = None, security_policy_name: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Instantiates an auto-scaling virtual server based on the selected file transfer protocol in Amazon Web Services.
    When you make updates to your file transfer protocol-enabled server or when you work with users, use the
    service-generated ServerId property that is assigned to the newly created server.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        certificate(Text, optional): The Amazon Resource Name (ARN) of the Amazon Web Services Certificate Manager (ACM) certificate.
            Required when Protocols is set to FTPS. To request a new public certificate, see Request a
            public certificate in the  Amazon Web Services Certificate Manager User Guide. To import an
            existing certificate into ACM, see Importing certificates into ACM in the  Amazon Web Services
            Certificate Manager User Guide. To request a private certificate to use FTPS through private IP
            addresses, see Request a private certificate in the  Amazon Web Services Certificate Manager
            User Guide. Certificates with the following cryptographic algorithms and key sizes are
            supported:   2048-bit RSA (RSA_2048)   4096-bit RSA (RSA_4096)   Elliptic Prime Curve 256 bit
            (EC_prime256v1)   Elliptic Prime Curve 384 bit (EC_secp384r1)   Elliptic Prime Curve 521 bit
            (EC_secp521r1)    The certificate must be a valid SSL/TLS X.509 version 3 certificate with FQDN
            or IP address specified and information about the issuer. Defaults to None.
        domain(Text, optional): The domain of the storage system that is used for file transfers. There are two domains
            available: Amazon Simple Storage Service (Amazon S3) and Amazon Elastic File System (Amazon
            EFS). The default value is S3.  After the server is created, the domain cannot be changed. Defaults to None.
        endpoint_details(Dict, optional): The virtual private cloud (VPC) endpoint settings that are configured for your server. When you
            host your endpoint within your VPC, you can make it accessible only to resources within your
            VPC, or you can attach Elastic IP addresses and make it accessible to clients over the internet.
            Your VPC's default security groups are automatically assigned to your endpoint. Defaults to None.
        endpoint_type(Text, optional): The type of endpoint that you want your server to use. You can choose to make your server's
            endpoint publicly accessible (PUBLIC) or host it inside your VPC. With an endpoint that is
            hosted in a VPC, you can restrict access to your server and resources only within your VPC or
            choose to make it internet facing by attaching Elastic IP addresses directly to it.   After May
            19, 2021, you won't be able to create a server using EndpointType=VPC_ENDPOINT in your Amazon
            Web Services account if your account hasn't already done so before May 19, 2021. If you have
            already created servers with EndpointType=VPC_ENDPOINT in your Amazon Web Services account on or
            before May 19, 2021, you will not be affected. After this date, use EndpointType=VPC. For more
            information, see https://docs.aws.amazon.com/transfer/latest/userguide/create-server-in-
            vpc.html#deprecate-vpc-endpoint. It is recommended that you use VPC as the EndpointType. With
            this endpoint type, you have the option to directly associate up to three Elastic IPv4 addresses
            (BYO IP included) with your server's endpoint and use VPC security groups to restrict traffic by
            the client's public IP address. This is not possible with EndpointType set to VPC_ENDPOINT. Defaults to None.
        host_key(Text, optional): The RSA private key as generated by the ssh-keygen -N "" -m PEM -f my-new-server-key command.
            If you aren't planning to migrate existing users from an existing SFTP-enabled server to a new
            server, don't update the host key. Accidentally changing a server's host key can be disruptive.
            For more information, see Change the host key for your SFTP-enabled server in the Amazon Web
            Services Transfer Family User Guide. Defaults to None.
        identity_provider_details(Dict, optional): Required when IdentityProviderType is set to AWS_DIRECTORY_SERVICE or API_GATEWAY. Accepts an
            array containing all of the information required to use a directory in AWS_DIRECTORY_SERVICE or
            invoke a customer-supplied authentication API, including the API Gateway URL. Not required when
            IdentityProviderType is set to SERVICE_MANAGED. Defaults to None.
        identity_provider_type(Text, optional): Specifies the mode of authentication for a server. The default value is SERVICE_MANAGED, which
            allows you to store and access user credentials within the Amazon Web Services Transfer Family
            service. Use AWS_DIRECTORY_SERVICE to provide access to Active Directory groups in Amazon Web
            Services Managed Active Directory or Microsoft Active Directory in your on-premises environment
            or in Amazon Web Services using AD Connectors. This option also requires you to provide a
            Directory ID using the IdentityProviderDetails parameter. Use the API_GATEWAY value to integrate
            with an identity provider of your choosing. The API_GATEWAY setting requires you to provide an
            API Gateway endpoint URL to call for authentication using the IdentityProviderDetails parameter. Defaults to None.
        logging_role(Text, optional): Specifies the Amazon Resource Name (ARN) of the Amazon Web Services Identity and Access
            Management (IAM) role that allows a server to turn on Amazon CloudWatch logging for Amazon S3 or
            Amazon EFS events. When set, user activity can be viewed in your CloudWatch logs. Defaults to None.
        protocols(List, optional): Specifies the file transfer protocol or protocols over which your file transfer protocol client
            can connect to your server's endpoint. The available protocols are:    SFTP (Secure Shell (SSH)
            File Transfer Protocol): File transfer over SSH    FTPS (File Transfer Protocol Secure): File
            transfer with TLS encryption    FTP (File Transfer Protocol): Unencrypted file transfer    If
            you select FTPS, you must choose a certificate stored in Amazon Web Services Certificate Manager
            (ACM) which is used to identify your server when clients connect to it over FTPS. If Protocol
            includes either FTP or FTPS, then the EndpointType must be VPC and the IdentityProviderType must
            be AWS_DIRECTORY_SERVICE or API_GATEWAY. If Protocol includes FTP, then AddressAllocationIds
            cannot be associated. If Protocol is set only to SFTP, the EndpointType can be set to PUBLIC and
            the IdentityProviderType can be set to SERVICE_MANAGED. Defaults to None.
        security_policy_name(Text, optional): Specifies the name of the security policy that is attached to the server. Defaults to None.
        tags(List, optional): Key-value pairs that can be used to group and search for servers. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.transfer.create_server(
                ctx,
                
                
                **{"Certificate": certificate, "Domain": domain, "EndpointDetails": endpoint_details, "EndpointType": endpoint_type, "HostKey": host_key, "IdentityProviderDetails": identity_provider_details, "IdentityProviderType": identity_provider_type, "LoggingRole": logging_role, "Protocols": protocols, "SecurityPolicyName": security_policy_name, "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.transfer.describe_server(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, server_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the file transfer protocol-enabled server that you specify. No response returns from this operation.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        server_id(Text): A unique system-assigned identifier for a server instance.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

