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

hub.exec.boto3.client.sagemaker_featurestore_runtime.delete_record
hub.exec.boto3.client.sagemaker_featurestore_runtime.get_record
hub.exec.boto3.client.sagemaker_featurestore_runtime.put_record
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, feature_group_name: Text, record: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Used for data ingestion into the FeatureStore. The PutRecord API writes to both the OnlineStore and
    OfflineStore. If the record is the latest record for the recordIdentifier, the record is written to both the
    OnlineStore and OfflineStore. If the record is a historic record, it is written only to the OfflineStore.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        feature_group_name(Text): The name of the feature group that you want to insert the record into.
        record(List): List of FeatureValues to be inserted. This will be a full over-write. If you only want to update
            few of the feature values, do the following:   Use GetRecord to retrieve the latest record.
            Update the record returned from GetRecord.    Use PutRecord to update feature values.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker_featurestore_runtime.put_record(
                ctx,
                
                
                **{"FeatureGroupName": feature_group_name, "Record": record}
            )
            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.sagemaker_featurestore_runtime.get_record(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, feature_group_name: Text, record_identifier_value_as_string: Text, event_time: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a Record from a FeatureGroup. A new record will show up in the OfflineStore when the DeleteRecord API is
    called. This record will have a value of True in the is_deleted column.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        feature_group_name(Text): The name of the feature group to delete the record from.
        record_identifier_value_as_string(Text): The value for the RecordIdentifier that uniquely identifies the record, in string format.
        event_time(Text): Timestamp indicating when the deletion event occurred. EventTime can be used to query data at a
            certain point in time.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.sagemaker_featurestore_runtime.record.absent:
                - name: value
                - feature_group_name: value
                - record_identifier_value_as_string: value
                - event_time: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker_featurestore_runtime.record.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.sagemaker_featurestore_runtime.get_record(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker_featurestore_runtime.delete_record(
                ctx,
                
                
                **{"FeatureGroupName": feature_group_name, "RecordIdentifierValueAsString": record_identifier_value_as_string, "EventTime": event_time}
            )
            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.sagemaker_featurestore_runtime.get_record(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

