Skip to content

list_image_referrers

list_image_referrers(
    repository_name: RepositoryName,
    subject_id: SubjectIdentifier,
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional[RegistryId] = None,
    filter: Optional[ListImageReferrersFilter] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[FiftyMaxResults] = None,
) -> ListImageReferrersResponse

Lists the artifacts associated with a specified subject image.

The IAM principal invoking this operation must have the ecr:BatchGetImage permission.

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 image referrers. If you do not specify a registry, the default registry is assumed.

  • repository_name (RepositoryName) –

    The name of the repository that contains the subject image.

  • subject_id (SubjectIdentifier) –

    An object containing the image digest of the subject image for which to retrieve associated artifacts.

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

    The filter key and value with which to filter your ListImageReferrers results. If no filter is specified, only artifacts with ACTIVE status are returned.

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

    The nextToken value returned from a previous paginated ListImageReferrers 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[FiftyMaxResults], default: None ) –

    The maximum number of image referrer results returned by ListImageReferrers in paginated output. When this parameter is used, ListImageReferrers 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 ListImageReferrers request with the returned nextToken value. This value can be between 1 and 50. If this parameter is not used, then ListImageReferrers returns up to 20 results and a nextToken value, if applicable.

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.

  • UnableToListUpstreamImageReferrersException –

    The referrer or referrers were unable to be listed using the pull through cache rule. This is usually caused because of an issue with the Secrets Manager secret containing the credentials for the upstream registry.

  • ValidationException –

    There was an exception validating this request.

  • UnknownServiceError –

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

Examples:

To list both active and archived artifacts This example lists all artifacts including those that have been archived, by specifying the artifactStatus filter as ANY.

>>> client.list_image_referrers(repository_name='sample-repo', subject_id={'imageDigest': 'sha256:943e640159415616581703a53fa4ed87e96740655fd67daf2d2146a35337bce5'}, filter={'artifactStatus': 'ANY'})
To list artifacts associated with a subject image
This example lists all artifacts (such as Sigstore signatures) that reference a specific container image in the sample-repo repository.
>>> client.list_image_referrers(repository_name='sample-repo', subject_id={'imageDigest': 'sha256:943e640159415616581703a53fa4ed87e96740655fd67daf2d2146a35337bce5'})
To list artifacts of a specific type
This example lists only Sigstore bundle artifacts associated with a subject image by filtering on the artifact type.
>>> client.list_image_referrers(repository_name='sample-repo', subject_id={'imageDigest': 'sha256:943e640159415616581703a53fa4ed87e96740655fd67daf2d2146a35337bce5'}, filter={'artifactTypes': ['application/vnd.dev.sigstore.bundle.v0.3+json']})
Source code in docs_src/capo_ecr/_services/ecr.py
def list_image_referrers(
    self,
    repository_name: "capo_ecr.types.repository_name.RepositoryName",
    subject_id: "capo_ecr.types.subject_identifier.SubjectIdentifier",
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional["capo_ecr.types.registry_id.RegistryId"] = None,
    filter: Optional[
        "capo_ecr.types.list_image_referrers_filter.ListImageReferrersFilter"
    ] = None,
    next_token: Optional["capo_ecr.types.next_token.NextToken"] = None,
    max_results: Optional[
        "capo_ecr.types.fifty_max_results.FiftyMaxResults"
    ] = None,
) -> "capo_ecr.types.list_image_referrers_response.ListImageReferrersResponse":
    """<p>Lists the artifacts associated with a specified subject image.</p> <note> <p>The IAM principal invoking this operation must have the <code>ecr:BatchGetImage</code> permission.</p> </note>

    Args:
        registry_id: <p>The Amazon Web Services account ID associated with the registry that contains the repository in which to list image referrers. If you do not specify a registry, the default registry is assumed.</p>
        repository_name: <p>The name of the repository that contains the subject image.</p>
        subject_id: <p>An object containing the image digest of the subject image for which to retrieve associated artifacts.</p>
        filter: <p>The filter key and value with which to filter your <code>ListImageReferrers</code> results. If no filter is specified, only artifacts with <code>ACTIVE</code> status are returned.</p>
        next_token: <p>The <code>nextToken</code> value returned from a previous paginated <code>ListImageReferrers</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 referrer results returned by <code>ListImageReferrers</code> in paginated output. When this parameter is used, <code>ListImageReferrers</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>ListImageReferrers</code> request with the returned <code>nextToken</code> value. This value can be between 1 and 50. If this parameter is not used, then <code>ListImageReferrers</code> returns up to 20 results and a <code>nextToken</code> value, if applicable.</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.unable_to_list_upstream_image_referrers_exception.UnableToListUpstreamImageReferrersException: <p>The referrer or referrers were unable to be listed using the pull through cache rule. This is usually caused because of an issue with the Secrets Manager secret containing the credentials for the upstream registry.</p>
        capo_ecr.errors.validation_exception.ValidationException: <p>There was an exception validating this request.</p>
        capo_ecr.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list both active and archived artifacts
        This example lists all artifacts including those that have been archived, by specifying the artifactStatus filter as ANY.

        >>> client.list_image_referrers(repository_name='sample-repo', subject_id={'imageDigest': 'sha256:943e640159415616581703a53fa4ed87e96740655fd67daf2d2146a35337bce5'}, filter={'artifactStatus': 'ANY'})
        To list artifacts associated with a subject image
        This example lists all artifacts (such as Sigstore signatures) that reference a specific container image in the sample-repo repository.

        >>> client.list_image_referrers(repository_name='sample-repo', subject_id={'imageDigest': 'sha256:943e640159415616581703a53fa4ed87e96740655fd67daf2d2146a35337bce5'})
        To list artifacts of a specific type
        This example lists only Sigstore bundle artifacts associated with a subject image by filtering on the artifact type.

        >>> client.list_image_referrers(repository_name='sample-repo', subject_id={'imageDigest': 'sha256:943e640159415616581703a53fa4ed87e96740655fd67daf2d2146a35337bce5'}, filter={'artifactTypes': ['application/vnd.dev.sigstore.bundle.v0.3+json']})
    """

    def _handler(
        req: "OperationRequest[capo_ecr.types.list_image_referrers_request.ListImageReferrersRequest]",
    ) -> OperationResponse[
        "capo_ecr.types.list_image_referrers_response.ListImageReferrersResponse"
    ]:
        import capo_ecr._operations.amazon_ec2_container_registry_v20150921.list_image_referrers

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

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

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