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

hub.exec.boto3.client.sagemaker.create_monitoring_schedule
hub.exec.boto3.client.sagemaker.delete_monitoring_schedule
hub.exec.boto3.client.sagemaker.describe_monitoring_schedule
hub.exec.boto3.client.sagemaker.list_monitoring_schedules
hub.exec.boto3.client.sagemaker.start_monitoring_schedule
hub.exec.boto3.client.sagemaker.stop_monitoring_schedule
hub.exec.boto3.client.sagemaker.update_monitoring_schedule
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, monitoring_schedule_name: Text, monitoring_schedule_config: Dict, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a schedule that regularly starts Amazon SageMaker Processing Jobs to monitor the data captured for an
    Amazon SageMaker Endoint.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        monitoring_schedule_name(Text): The name of the monitoring schedule. The name must be unique within an Amazon Web Services
            Region within an Amazon Web Services account.
        monitoring_schedule_config(Dict): The configuration object that specifies the monitoring schedule and defines the monitoring job.
        tags(List, optional): (Optional) An array of key-value pairs. For more information, see Using Cost Allocation Tags in
            the Amazon Web Services Billing and Cost Management User Guide. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.sagemaker.monitoring_schedule.present:
                - name: value
                - monitoring_schedule_name: value
                - monitoring_schedule_config: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker.monitoring_schedule.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_monitoring_schedule(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_monitoring_schedule(
                ctx,
                
                
                **{"MonitoringScheduleName": monitoring_schedule_name, "MonitoringScheduleConfig": monitoring_schedule_config, "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_monitoring_schedule(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, monitoring_schedule_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a monitoring schedule. Also stops the schedule had not already been stopped. This does not delete the
    job execution history of the monitoring schedule.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        monitoring_schedule_name(Text): The name of the monitoring schedule to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

