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

hub.exec.boto3.client.customer_profiles.delete_integration
hub.exec.boto3.client.customer_profiles.get_integration
hub.exec.boto3.client.customer_profiles.list_integrations
hub.exec.boto3.client.customer_profiles.put_integration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, domain_name: Text, object_type_name: Text, uri: Text = None, tags: Dict = None, flow_definition: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Adds an integration between the service and a third-party service, which includes Amazon AppFlow and Amazon
    Connect. An integration can belong to only one domain.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_name(Text): The unique name of the domain.
        uri(Text, optional): The URI of the S3 bucket or any other type of data source. Defaults to None.
        object_type_name(Text): The name of the profile object type.
        tags(Dict, optional): The tags used to organize, track, or control access for this resource. Defaults to None.
        flow_definition(Dict, optional): The configuration that controls how Customer Profiles retrieves data from the source. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.customer_profiles.put_integration(
                ctx,
                
                
                **{"DomainName": domain_name, "Uri": uri, "ObjectTypeName": object_type_name, "Tags": tags, "FlowDefinition": flow_definition}
            )
            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.customer_profiles.get_integration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, domain_name: Text, uri: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes an integration from a specific domain.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_name(Text): The unique name of the domain.
        uri(Text): The URI of the S3 bucket or any other type of data source.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.customer_profiles.integration.absent:
                - name: value
                - domain_name: value
                - uri: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.customer_profiles.integration.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.customer_profiles.get_integration(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.customer_profiles.delete_integration(
                ctx,
                
                
                **{"DomainName": domain_name, "Uri": uri}
            )
            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.customer_profiles.get_integration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

