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

hub.exec.boto3.client.appflow.create_connector_profile
hub.exec.boto3.client.appflow.delete_connector_profile
hub.exec.boto3.client.appflow.describe_connector_profiles
hub.exec.boto3.client.appflow.update_connector_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, connector_profile_name: Text, connector_type: Text, connection_mode: Text, connector_profile_config: Dict, kms_arn: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates a new connector profile associated with your AWS account. There is a soft quota of 100 connector
    profiles per AWS account. If you need more connector profiles than this quota allows, you can submit a request
    to the Amazon AppFlow team through the Amazon AppFlow support channel.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        connector_profile_name(Text):  The name of the connector profile. The name is unique for each ConnectorProfile in your AWS
            account.
        kms_arn(Text, optional):  The ARN (Amazon Resource Name) of the Key Management Service (KMS) key you provide for
            encryption. This is required if you do not want to use the Amazon AppFlow-managed KMS key. If
            you don't provide anything here, Amazon AppFlow uses the Amazon AppFlow-managed KMS key. Defaults to None.
        connector_type(Text):  The type of connector, such as Salesforce, Amplitude, and so on.
        connection_mode(Text):  Indicates the connection mode and specifies whether it is public or private. Private flows use
            AWS PrivateLink to route data over AWS infrastructure without exposing it to the public
            internet.
        connector_profile_config(Dict):  Defines the connector-specific configuration and credentials.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.appflow.connector_profile.present:
                - name: value
                - connector_profile_name: value
                - connector_type: value
                - connection_mode: value
                - connector_profile_config: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.appflow.connector_profile.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.appflow.describe_connector_profiles(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.appflow.create_connector_profile(
                ctx,
                
                
                **{"connectorProfileName": connector_profile_name, "kmsArn": kms_arn, "connectorType": connector_type, "connectionMode": connection_mode, "connectorProfileConfig": connector_profile_config}
            )
            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.appflow.describe_connector_profiles(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, connector_profile_name: Text, force_delete: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Enables you to delete an existing connector profile.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        connector_profile_name(Text):  The name of the connector profile. The name is unique for each ConnectorProfile in your
            account.
        force_delete(bool, optional):  Indicates whether Amazon AppFlow should delete the profile, even if it is currently in use in
            one or more flows. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.appflow.delete_connector_profile(
                ctx,
                
                
                **{"connectorProfileName": connector_profile_name, "forceDelete": force_delete}
            )
            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.appflow.describe_connector_profiles(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

