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

hub.exec.boto3.client.sagemaker.create_feature_group
hub.exec.boto3.client.sagemaker.delete_feature_group
hub.exec.boto3.client.sagemaker.describe_feature_group
hub.exec.boto3.client.sagemaker.list_feature_groups
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, feature_group_name: Text, record_identifier_feature_name: Text, event_time_feature_name: Text, feature_definitions: List, online_store_config: Dict = None, offline_store_config: Dict = None, role_arn: Text = None, description: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a new FeatureGroup. A FeatureGroup is a group of Features defined in the FeatureStore to describe a
    Record.  The FeatureGroup defines the schema and features contained in the FeatureGroup. A FeatureGroup
    definition is composed of a list of Features, a RecordIdentifierFeatureName, an EventTimeFeatureName and
    configurations for its OnlineStore and OfflineStore. Check Amazon Web Services service quotas to see the
    FeatureGroups quota for your Amazon Web Services account.  You must include at least one of OnlineStoreConfig
    and OfflineStoreConfig to create a FeatureGroup.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        feature_group_name(Text): The name of the FeatureGroup. The name must be unique within an Amazon Web Services Region in an
            Amazon Web Services account. The name:   Must start and end with an alphanumeric character.
            Can only contain alphanumeric character and hyphens. Spaces are not allowed.
        record_identifier_feature_name(Text): The name of the Feature whose value uniquely identifies a Record defined in the FeatureStore.
            Only the latest record per identifier value will be stored in the OnlineStore.
            RecordIdentifierFeatureName must be one of feature definitions' names. You use the
            RecordIdentifierFeatureName to access data in a FeatureStore. This name:   Must start and end
            with an alphanumeric character.   Can only contains alphanumeric characters, hyphens,
            underscores. Spaces are not allowed.
        event_time_feature_name(Text): The name of the feature that stores the EventTime of a Record in a FeatureGroup. An EventTime is
            a point in time when a new event occurs that corresponds to the creation or update of a Record
            in a FeatureGroup. All Records in the FeatureGroup must have a corresponding EventTime. An
            EventTime can be a String or Fractional.     Fractional: EventTime feature values must be a Unix
            timestamp in seconds.    String: EventTime feature values must be an ISO-8601 string in the
            format. The following formats are supported yyyy-MM-dd'T'HH:mm:ssZ and yyyy-MM-
            dd'T'HH:mm:ss.SSSZ where yyyy, MM, and dd represent the year, month, and day respectively and
            HH, mm, ss, and if applicable, SSS represent the hour, month, second and milliseconds
            respsectively. 'T' and Z are constants.
        feature_definitions(List): A list of Feature names and types. Name and Type is compulsory per Feature.  Valid feature
            FeatureTypes are Integral, Fractional and String.  FeatureNames cannot be any of the following:
            is_deleted, write_time, api_invocation_time  You can create up to 2,500 FeatureDefinitions per
            FeatureGroup.
        online_store_config(Dict, optional): You can turn the OnlineStore on or off by specifying True for the EnableOnlineStore flag in
            OnlineStoreConfig; the default value is False. You can also include an Amazon Web Services KMS
            key ID (KMSKeyId) for at-rest encryption of the OnlineStore. Defaults to None.
        offline_store_config(Dict, optional): Use this to configure an OfflineFeatureStore. This parameter allows you to specify:   The Amazon
            Simple Storage Service (Amazon S3) location of an OfflineStore.   A configuration for an Amazon
            Web Services Glue or Amazon Web Services Hive data cataolgue.    An KMS encryption key to
            encrypt the Amazon S3 location used for OfflineStore.   To learn more about this parameter, see
            OfflineStoreConfig. Defaults to None.
        role_arn(Text, optional): The Amazon Resource Name (ARN) of the IAM execution role used to persist data into the
            OfflineStore if an OfflineStoreConfig is provided. Defaults to None.
        description(Text, optional): A free-form description of a FeatureGroup. Defaults to None.
        tags(List, optional): Tags used to identify Features in each FeatureGroup. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.sagemaker.feature_group.present:
                - name: value
                - feature_group_name: value
                - record_identifier_feature_name: value
                - event_time_feature_name: value
                - feature_definitions: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker.feature_group.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.describe_feature_group(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_feature_group(
                ctx,
                
                
                **{"FeatureGroupName": feature_group_name, "RecordIdentifierFeatureName": record_identifier_feature_name, "EventTimeFeatureName": event_time_feature_name, "FeatureDefinitions": feature_definitions, "OnlineStoreConfig": online_store_config, "OfflineStoreConfig": offline_store_config, "RoleArn": role_arn, "Description": description, "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.sagemaker.describe_feature_group(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, feature_group_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete the FeatureGroup and any data that was written to the OnlineStore of the FeatureGroup. Data cannot be
    accessed from the OnlineStore immediately after DeleteFeatureGroup is called.  Data written into the
    OfflineStore will not be deleted. The Amazon Web Services Glue database and tables that are automatically
    created for your OfflineStore are not deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        feature_group_name(Text): The name of the FeatureGroup you want to delete. The name must be unique within an Amazon Web
            Services Region in an Amazon Web Services account.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

