Skip to content

list_images

list_images(
    repository_name: RepositoryName,
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional[RegistryId] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
    filter: Optional[ListImagesFilter] = None,
) -> ListImagesResponse

Lists all the image IDs for the specified repository.

You can filter images based on whether or not they are tagged by using the tagStatus filter and specifying either TAGGED, UNTAGGED or ANY. For example, you can filter your results to return only UNTAGGED images and then pipe that result to a BatchDeleteImage operation to delete them. Or, you can filter your results to return only TAGGED images to list all of the tags in your repository.

Parameters:

  • registry_id (Optional[RegistryId], default: None ) –

    The Amazon Web Services account ID associated with the registry that contains the repository in which to list images. If you do not specify a registry, the default registry is assumed.

  • repository_name (RepositoryName) –

    The repository with image IDs to be listed.

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

    The nextToken value returned from a previous paginated ListImages request where maxResults was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the nextToken value. This value is null when there are no more results to return.

    This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.

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

    The maximum number of image results returned by ListImages in paginated output. When this parameter is used, ListImages only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListImages request with the returned nextToken value. This value can be between 1 and 1000. If this parameter is not used, then ListImages returns up to 100 results and a nextToken value, if applicable.

  • filter (Optional[ListImagesFilter], default: None ) –

    The filter key and value with which to filter your ListImages results.

Raises:

  • InvalidParameterException –

    The specified parameter is invalid. Review the available parameters for the API request.

  • RepositoryNotFoundException –

    The specified repository could not be found. Check the spelling of the specified repository and ensure that you are performing operations on the correct registry.

  • ServerException –

    These errors are usually caused by a server-side issue.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To list all images in a repository This example lists all of the images in the repository named ubuntu in the default registry in the current account.

>>> client.list_images(repository_name='ubuntu')
Source code in docs_src/capo_ecr/_services/ecr.py
def list_images(
    self,
    repository_name: "capo_ecr.types.repository_name.RepositoryName",
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional["capo_ecr.types.registry_id.RegistryId"] = None,
    next_token: Optional["capo_ecr.types.next_token.NextToken"] = None,
    max_results: Optional["capo_ecr.types.max_results.MaxResults"] = None,
    filter: Optional["capo_ecr.types.list_images_filter.ListImagesFilter"] = None,
) -> "capo_ecr.types.list_images_response.ListImagesResponse":
    """<p>Lists all the image IDs for the specified repository.</p> <p>You can filter images based on whether or not they are tagged by using the <code>tagStatus</code> filter and specifying either <code>TAGGED</code>, <code>UNTAGGED</code> or <code>ANY</code>. For example, you can filter your results to return only <code>UNTAGGED</code> images and then pipe that result to a <a>BatchDeleteImage</a> operation to delete them. Or, you can filter your results to return only <code>TAGGED</code> images to list all of the tags in your repository.</p>

    Args:
        registry_id: <p>The Amazon Web Services account ID associated with the registry that contains the repository in which to list images. If you do not specify a registry, the default registry is assumed.</p>
        repository_name: <p>The repository with image IDs to be listed.</p>
        next_token: <p>The <code>nextToken</code> value returned from a previous paginated <code>ListImages</code> request where <code>maxResults</code> was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the <code>nextToken</code> value. This value is <code>null</code> when there are no more results to return.</p> <note> <p>This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.</p> </note>
        max_results: <p>The maximum number of image results returned by <code>ListImages</code> in paginated output. When this parameter is used, <code>ListImages</code> only returns <code>maxResults</code> results in a single page along with a <code>nextToken</code> response element. The remaining results of the initial request can be seen by sending another <code>ListImages</code> request with the returned <code>nextToken</code> value. This value can be between 1 and 1000. If this parameter is not used, then <code>ListImages</code> returns up to 100 results and a <code>nextToken</code> value, if applicable.</p>
        filter: <p>The filter key and value with which to filter your <code>ListImages</code> results.</p>

    Raises:
        capo_ecr.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_ecr.errors.repository_not_found_exception.RepositoryNotFoundException: <p>The specified repository could not be found. Check the spelling of the specified repository and ensure that you are performing operations on the correct registry.</p>
        capo_ecr.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue.</p>
        capo_ecr.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list all images in a repository
        This example lists all of the images in the repository named ubuntu in the default registry in the current account.

        >>> client.list_images(repository_name='ubuntu')
    """

    def _handler(
        req: "OperationRequest[capo_ecr.types.list_images_request.ListImagesRequest]",
    ) -> OperationResponse[
        "capo_ecr.types.list_images_response.ListImagesResponse"
    ]:
        import capo_ecr._operations.amazon_ec2_container_registry_v20150921.list_images

        output, http_response = (
            capo_ecr._operations.amazon_ec2_container_registry_v20150921.list_images.list_images(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListImages")
    )
    input_: capo_ecr.types.list_images_request.ListImagesRequest = {
        "repository_name": repository_name
    }
    if registry_id is not None:
        input_["registry_id"] = registry_id
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if filter is not None:
        input_["filter"] = filter

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