Skip to content

list_model_packages

list_model_packages(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    creation_time_after: Optional[CreationTime] = None,
    creation_time_before: Optional[CreationTime] = None,
    max_results: Optional[MaxResults] = None,
    name_contains: Optional[NameContains] = None,
    model_approval_status: Optional[ModelApprovalStatus] = None,
    model_package_group_name: Optional[ArnOrName] = None,
    model_package_type: Optional[ModelPackageType] = None,
    next_token: Optional[NextToken] = None,
    sort_by: Optional[ModelPackageSortBy] = None,
    sort_order: Optional[SortOrder] = None,
) -> ListModelPackagesOutput

Lists the model packages that have been created.

Parameters:

  • creation_time_after (Optional[CreationTime], default: None ) –

    A filter that returns only model packages created after the specified time (timestamp).

  • creation_time_before (Optional[CreationTime], default: None ) –

    A filter that returns only model packages created before the specified time (timestamp).

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of model packages to return in the response.

  • name_contains (Optional[NameContains], default: None ) –

    A string in the model package name. This filter returns only model packages whose name contains the specified string.

  • model_approval_status (Optional[ModelApprovalStatus], default: None ) –

    A filter that returns only the model packages with the specified approval status.

  • model_package_group_name (Optional[ArnOrName], default: None ) –

    A filter that returns only model versions that belong to the specified model group.

  • model_package_type (Optional[ModelPackageType], default: None ) –

    A filter that returns only the model packages of the specified type. This can be one of the following values.

    • UNVERSIONED - List only unversioined models. This is the default value if no ModelPackageType is specified.

    • VERSIONED - List only versioned models.

    • BOTH - List both versioned and unversioned models.

  • next_token (Optional[NextToken], default: None ) –

    If the response to a previous ListModelPackages request was truncated, the response includes a NextToken. To retrieve the next set of model packages, use the token in the next request.

  • sort_by (Optional[ModelPackageSortBy], default: None ) –

    The parameter by which to sort the results. The default is CreationTime.

  • sort_order (Optional[SortOrder], default: None ) –

    The sort order for the results. The default is Ascending.

Raises:

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def list_model_packages(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    creation_time_after: Optional[
        "capo_sagemaker.types.creation_time.CreationTime"
    ] = None,
    creation_time_before: Optional[
        "capo_sagemaker.types.creation_time.CreationTime"
    ] = None,
    max_results: Optional["capo_sagemaker.types.max_results.MaxResults"] = None,
    name_contains: Optional[
        "capo_sagemaker.types.name_contains.NameContains"
    ] = None,
    model_approval_status: Optional[
        "capo_sagemaker.types.model_approval_status.ModelApprovalStatus"
    ] = None,
    model_package_group_name: Optional[
        "capo_sagemaker.types.arn_or_name.ArnOrName"
    ] = None,
    model_package_type: Optional[
        "capo_sagemaker.types.model_package_type.ModelPackageType"
    ] = None,
    next_token: Optional["capo_sagemaker.types.next_token.NextToken"] = None,
    sort_by: Optional[
        "capo_sagemaker.types.model_package_sort_by.ModelPackageSortBy"
    ] = None,
    sort_order: Optional["capo_sagemaker.types.sort_order.SortOrder"] = None,
) -> "capo_sagemaker.types.list_model_packages_output.ListModelPackagesOutput":
    """<p>Lists the model packages that have been created.</p>

    Args:
        creation_time_after: <p>A filter that returns only model packages created after the specified time (timestamp).</p>
        creation_time_before: <p>A filter that returns only model packages created before the specified time (timestamp).</p>
        max_results: <p>The maximum number of model packages to return in the response.</p>
        name_contains: <p>A string in the model package name. This filter returns only model packages whose name contains the specified string.</p>
        model_approval_status: <p>A filter that returns only the model packages with the specified approval status.</p>
        model_package_group_name: <p>A filter that returns only model versions that belong to the specified model group.</p>
        model_package_type: <p>A filter that returns only the model packages of the specified type. This can be one of the following values.</p> <ul> <li> <p> <code>UNVERSIONED</code> - List only unversioined models. This is the default value if no <code>ModelPackageType</code> is specified.</p> </li> <li> <p> <code>VERSIONED</code> - List only versioned models.</p> </li> <li> <p> <code>BOTH</code> - List both versioned and unversioned models.</p> </li> </ul>
        next_token: <p>If the response to a previous <code>ListModelPackages</code> request was truncated, the response includes a <code>NextToken</code>. To retrieve the next set of model packages, use the token in the next request.</p>
        sort_by: <p>The parameter by which to sort the results. The default is <code>CreationTime</code>.</p>
        sort_order: <p>The sort order for the results. The default is <code>Ascending</code>.</p>

    Raises:
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.list_model_packages_input.ListModelPackagesInput]",
    ) -> OperationResponse[
        "capo_sagemaker.types.list_model_packages_output.ListModelPackagesOutput"
    ]:
        import capo_sagemaker._operations.sage_maker.list_model_packages

        output, http_response = (
            capo_sagemaker._operations.sage_maker.list_model_packages.list_model_packages(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListModelPackages")
    )
    input_: capo_sagemaker.types.list_model_packages_input.ListModelPackagesInput = {}
    if creation_time_after is not None:
        input_["creation_time_after"] = creation_time_after
    if creation_time_before is not None:
        input_["creation_time_before"] = creation_time_before
    if max_results is not None:
        input_["max_results"] = max_results
    if name_contains is not None:
        input_["name_contains"] = name_contains
    if model_approval_status is not None:
        input_["model_approval_status"] = model_approval_status
    if model_package_group_name is not None:
        input_["model_package_group_name"] = model_package_group_name
    if model_package_type is not None:
        input_["model_package_type"] = model_package_type
    if next_token is not None:
        input_["next_token"] = next_token
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if sort_order is not None:
        input_["sort_order"] = sort_order

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output