Skip to content

set_image_status async

set_image_status(
    repository_name: RepositoryName,
    repository_type: RepositoryType,
    image_id: ImageIdentifier,
    status: ImageStatus,
    *,
    config_overrides: Optional[AsyncECRPUBLICClientConfig] = None,
    registry_id: Optional[RegistryId] = None,
    deprecation_period_days: Optional[DeprecationPeriodDays] = None,
) -> SetImageStatusResponse

Sets the status of an image in a premium repository to ACTIVE or DEPRECATED. When you deprecate an image, Amazon ECR deletes it after the deprecation period ends. You can't use this operation while the repository is in the DRAFT state.

Parameters:

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

    The Amazon Web Services account ID that's associated with the public registry that contains the image. If you do not specify a registry, the default public registry is assumed. You can specify only your own account ID. Cross-account access through a repository policy isn't supported for this operation.

  • repository_name (RepositoryName) –

    The name of the repository that contains the image.

  • repository_type (RepositoryType) –

    The type of the repository. You can set the image status only in a PREMIUM repository.

  • image_id (ImageIdentifier) –

    The image ID of the image to set the status for. If you specify a tag, the tag is resolved to the digest of the image that it currently points to, and the status is set on that image.

  • status (ImageStatus) –

    The status to set on the image. Valid values:

    • ACTIVE: Cancels a pending deletion. You can do this only before the scheduled deletion time.

    • DEPRECATED: Schedules the image for deletion after the deprecation period.

    After the scheduled deletion time, you can't change the status of the image.

    If the image is part of a manifest list, Amazon ECR requires that a manifest list is deleted before the images that it references. To deprecate an image that a manifest list references, deprecate the manifest list first, with a scheduled deletion time before the image's. You can't set a manifest list to ACTIVE while it references deprecated images. Requests that break these rules fail with ValidationException.

  • deprecation_period_days (Optional[DeprecationPeriodDays], default: None ) –

    The number of days that Amazon ECR waits before it deletes the deprecated image. You can specify a value between 90 and 365. This parameter is required when you set status to DEPRECATED. Don't specify it when you set status to ACTIVE.

Raises:

  • ConflictException –

    Another operation is in progress on the same resource. Wait and then retry the request.

  • ImageNotFoundException –

    The image requested doesn't exist in the specified repository. Check the image tag or digest. To list the images in a repository, use DescribeImages or DescribeImageTags, or for a premium repository that you're entitled to, DescribeEntitledImages or DescribeEntitledImageTags.

  • InvalidParameterException –

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

  • RepositoryNotFoundException –

    The specified repository can't be found. Check the spelling of the specified repository and ensure that you're performing operations on the correct registry.

  • ServerException –

    These errors are usually caused by a server-side issue. Retry the request. If it continues to fail, contact Amazon Web Services Support.

  • UnsupportedCommandException –

    The action isn't supported in this Region. Check that the action is available in the Amazon Web Services Region that you're using, and try again in a supported Region.

  • ValidationException –

    There was an error validating the request. Check the request parameters and try again.

  • UnknownServiceError –

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

Examples:

To deprecate an image in a premium repository This example deprecates an image in the premium repository my-premium-repository with a 90-day deprecation period. Amazon ECR deletes the image within 24 hours after the scheduled deletion time.

>>> await client.set_image_status(repository_name='my-premium-repository', repository_type='PREMIUM', image_id={'imageDigest': 'sha256:f5c12bd3e4b8b1a2a3a5d5d0e6c4b3a2f1e0d9c8b7a6f5e4d3c2b1a0f9e8d7c6'}, status='DEPRECATED', deprecation_period_days=90)
Source code in docs_src/capo_ecr_public/_services/async_ecrpublic.py
async def set_image_status(
    self,
    repository_name: "capo_ecr_public.types.repository_name.RepositoryName",
    repository_type: "capo_ecr_public.types.repository_type.RepositoryType",
    image_id: "capo_ecr_public.types.image_identifier.ImageIdentifier",
    status: "capo_ecr_public.types.image_status.ImageStatus",
    *,
    config_overrides: Optional[AsyncECRPUBLICClientConfig] = None,
    registry_id: Optional["capo_ecr_public.types.registry_id.RegistryId"] = None,
    deprecation_period_days: Optional[
        "capo_ecr_public.types.deprecation_period_days.DeprecationPeriodDays"
    ] = None,
) -> "capo_ecr_public.types.set_image_status_response.SetImageStatusResponse":
    """<p>Sets the status of an image in a premium repository to <code>ACTIVE</code> or <code>DEPRECATED</code>. When you deprecate an image, Amazon ECR deletes it after the deprecation period ends. You can't use this operation while the repository is in the <code>DRAFT</code> state.</p>

    Args:
        registry_id: <p>The Amazon Web Services account ID that's associated with the public registry that contains the image. If you do not specify a registry, the default public registry is assumed. You can specify only your own account ID. Cross-account access through a repository policy isn't supported for this operation.</p>
        repository_name: <p>The name of the repository that contains the image.</p>
        repository_type: <p>The type of the repository. You can set the image status only in a <code>PREMIUM</code> repository.</p>
        image_id: <p>The image ID of the image to set the status for. If you specify a tag, the tag is resolved to the digest of the image that it currently points to, and the status is set on that image.</p>
        status: <p>The status to set on the image. Valid values:</p> <ul> <li> <p> <code>ACTIVE</code>: Cancels a pending deletion. You can do this only before the scheduled deletion time.</p> </li> <li> <p> <code>DEPRECATED</code>: Schedules the image for deletion after the deprecation period.</p> </li> </ul> <p>After the scheduled deletion time, you can't change the status of the image.</p> <p>If the image is part of a manifest list, Amazon ECR requires that a manifest list is deleted before the images that it references. To deprecate an image that a manifest list references, deprecate the manifest list first, with a scheduled deletion time before the image's. You can't set a manifest list to <code>ACTIVE</code> while it references deprecated images. Requests that break these rules fail with <code>ValidationException</code>.</p>
        deprecation_period_days: <p>The number of days that Amazon ECR waits before it deletes the deprecated image. You can specify a value between 90 and 365. This parameter is required when you set <code>status</code> to <code>DEPRECATED</code>. Don't specify it when you set <code>status</code> to <code>ACTIVE</code>.</p>

    Raises:
        capo_ecr_public.errors.conflict_exception.ConflictException: <p>Another operation is in progress on the same resource. Wait and then retry the request.</p>
        capo_ecr_public.errors.image_not_found_exception.ImageNotFoundException: <p>The image requested doesn't exist in the specified repository. Check the image tag or digest. To list the images in a repository, use <code>DescribeImages</code> or <code>DescribeImageTags</code>, or for a premium repository that you're entitled to, <code>DescribeEntitledImages</code> or <code>DescribeEntitledImageTags</code>.</p>
        capo_ecr_public.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_ecr_public.errors.repository_not_found_exception.RepositoryNotFoundException: <p>The specified repository can't be found. Check the spelling of the specified repository and ensure that you're performing operations on the correct registry.</p>
        capo_ecr_public.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue. Retry the request. If it continues to fail, contact Amazon Web Services Support.</p>
        capo_ecr_public.errors.unsupported_command_exception.UnsupportedCommandException: <p>The action isn't supported in this Region. Check that the action is available in the Amazon Web Services Region that you're using, and try again in a supported Region.</p>
        capo_ecr_public.errors.validation_exception.ValidationException: <p>There was an error validating the request. Check the request parameters and try again.</p>
        capo_ecr_public.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To deprecate an image in a premium repository
        This example deprecates an image in the premium repository my-premium-repository with a 90-day deprecation period. Amazon ECR deletes the image within 24 hours after the scheduled deletion time.

        >>> await client.set_image_status(repository_name='my-premium-repository', repository_type='PREMIUM', image_id={'imageDigest': 'sha256:f5c12bd3e4b8b1a2a3a5d5d0e6c4b3a2f1e0d9c8b7a6f5e4d3c2b1a0f9e8d7c6'}, status='DEPRECATED', deprecation_period_days=90)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ecr_public.types.set_image_status_request.SetImageStatusRequest]",
    ) -> AsyncOperationResponse[
        "capo_ecr_public.types.set_image_status_response.SetImageStatusResponse"
    ]:
        import capo_ecr_public._operations.spencer_frontend_service.set_image_status

        (
            output,
            http_response,
        ) = await capo_ecr_public._operations.spencer_frontend_service.set_image_status.async_set_image_status(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SetImageStatus")
    )
    input_: capo_ecr_public.types.set_image_status_request.SetImageStatusRequest = {
        "repository_name": repository_name,
        "repository_type": repository_type,
        "image_id": image_id,
        "status": status,
    }
    if registry_id is not None:
        input_["registry_id"] = registry_id
    if deprecation_period_days is not None:
        input_["deprecation_period_days"] = deprecation_period_days

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output