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

hub.exec.boto3.client.sagemaker.create_model_package
hub.exec.boto3.client.sagemaker.delete_model_package
hub.exec.boto3.client.sagemaker.describe_model_package
hub.exec.boto3.client.sagemaker.list_model_packages
hub.exec.boto3.client.sagemaker.update_model_package
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, model_package_name: Text = None, model_package_group_name: Text = None, model_package_description: Text = None, inference_specification: Dict = None, validation_specification: Dict = None, source_algorithm_specification: Dict = None, certify_for_marketplace: bool = None, tags: List = None, model_approval_status: Text = None, metadata_properties: Dict = None, model_metrics: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a model package that you can use to create Amazon SageMaker models or list on Amazon Web Services
    Marketplace, or a versioned model that is part of a model group. Buyers can subscribe to model packages listed
    on Amazon Web Services Marketplace to create models in Amazon SageMaker. To create a model package by specifying
    a Docker container that contains your inference code and the Amazon S3 location of your model artifacts, provide
    values for InferenceSpecification. To create a model from an algorithm resource that you created or subscribed
    to in Amazon Web Services Marketplace, provide a value for SourceAlgorithmSpecification.  There are two types of
    model packages:   Versioned - a model that is part of a model group in the model registry.   Unversioned - a
    model package that is not part of a model group.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_package_name(Text, optional): The name of the model package. The name must have 1 to 63 characters. Valid characters are a-z,
            A-Z, 0-9, and - (hyphen). This parameter is required for unversioned models. It is not
            applicable to versioned models. Defaults to None.
        model_package_group_name(Text, optional): The name of the model group that this model version belongs to. This parameter is required for
            versioned models, and does not apply to unversioned models. Defaults to None.
        model_package_description(Text, optional): A description of the model package. Defaults to None.
        inference_specification(Dict, optional): Specifies details about inference jobs that can be run with models based on this model package,
            including the following:   The Amazon ECR paths of containers that contain the inference code
            and model artifacts.   The instance types that the model package supports for transform jobs and
            real-time endpoints used for inference.   The input and output content formats that the model
            package supports for inference. Defaults to None.
        validation_specification(Dict, optional): Specifies configurations for one or more transform jobs that Amazon SageMaker runs to test the
            model package. Defaults to None.
        source_algorithm_specification(Dict, optional): Details about the algorithm that was used to create the model package. Defaults to None.
        certify_for_marketplace(bool, optional): Whether to certify the model package for listing on Amazon Web Services Marketplace. This
            parameter is optional for unversioned models, and does not apply to versioned models. Defaults to None.
        tags(List, optional): A list of key value pairs associated with the model. For more information, see Tagging Amazon
            Web Services resources in the Amazon Web Services General Reference Guide. Defaults to None.
        model_approval_status(Text, optional): Whether the model is approved for deployment. This parameter is optional for versioned models,
            and does not apply to unversioned models. For versioned models, the value of this parameter must
            be set to Approved to deploy the model. Defaults to None.
        metadata_properties(Dict, optional): Metadata properties of the tracking entity, trial, or trial component. Defaults to None.
        model_metrics(Dict, optional): A structure that contains model metrics reports. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_model_package(
                ctx,
                
                ClientToken=name,
                **{"ModelPackageName": model_package_name, "ModelPackageGroupName": model_package_group_name, "ModelPackageDescription": model_package_description, "InferenceSpecification": inference_specification, "ValidationSpecification": validation_specification, "SourceAlgorithmSpecification": source_algorithm_specification, "CertifyForMarketplace": certify_for_marketplace, "Tags": tags, "ModelApprovalStatus": model_approval_status, "MetadataProperties": metadata_properties, "ModelMetrics": model_metrics}
            )
            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_model_package(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, model_package_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a model package. A model package is used to create Amazon SageMaker models or list on Amazon Web
    Services Marketplace. Buyers can subscribe to model packages listed on Amazon Web Services Marketplace to create
    models in Amazon SageMaker.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_package_name(Text): The name or Amazon Resource Name (ARN) of the model package to delete. When you specify a name,
            the name must have 1 to 63 characters. Valid characters are a-z, A-Z, 0-9, and - (hyphen).

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

