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

hub.exec.boto3.client.frauddetector.create_variable
hub.exec.boto3.client.frauddetector.delete_variable
hub.exec.boto3.client.frauddetector.get_variables
hub.exec.boto3.client.frauddetector.update_variable
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, data_type: Text, data_source: Text, default_value: Text, description: Text = None, variable_type: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a variable.

    Args:
        name(Text): The name of the variable.
        data_type(Text): The data type.
        data_source(Text): The source of the data.
        default_value(Text): The default value for the variable when no value is received.
        description(Text, optional): The description. Defaults to None.
        variable_type(Text, optional): The variable type. For more information see Variable types.  Valid Values: AUTH_CODE | AVS |
            BILLING_ADDRESS_L1 | BILLING_ADDRESS_L2 | BILLING_CITY | BILLING_COUNTRY | BILLING_NAME |
            BILLING_PHONE | BILLING_STATE | BILLING_ZIP | CARD_BIN | CATEGORICAL | CURRENCY_CODE |
            EMAIL_ADDRESS | FINGERPRINT | FRAUD_LABEL | FREE_FORM_TEXT | IP_ADDRESS | NUMERIC | ORDER_ID |
            PAYMENT_TYPE | PHONE_NUMBER | PRICE | PRODUCT_CATEGORY | SHIPPING_ADDRESS_L1 |
            SHIPPING_ADDRESS_L2 | SHIPPING_CITY | SHIPPING_COUNTRY | SHIPPING_NAME | SHIPPING_PHONE |
            SHIPPING_STATE | SHIPPING_ZIP | USERAGENT. Defaults to None.
        tags(List, optional): A collection of key and value pairs. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.frauddetector.variable.present:
                - name: value
                - data_type: value
                - data_source: value
                - default_value: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.frauddetector.variable.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.frauddetector.get_variables(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.frauddetector.create_variable(
                ctx,
                
                
                **{"Name": name, "dataType": data_type, "dataSource": data_source, "defaultValue": default_value, "description": description, "variableType": variable_type, "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.frauddetector.get_variables(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a variable. You can't delete variables that are included in an event type in Amazon Fraud Detector.
    Amazon Fraud Detector automatically deletes model output variables and SageMaker model output variables when you
    delete the model. You can't delete these variables manually. When you delete a variable, Amazon Fraud Detector
    permanently deletes that variable and the data is no longer stored in Amazon Fraud Detector.

    Args:
        name(Text): The name of the variable to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

