set_image_status
¶
set_image_status(
repository_name: RepositoryName,
repository_type: RepositoryType,
image_id: ImageIdentifier,
status: ImageStatus,
*,
config_overrides: Optional[ECRPUBLICClientConfig] = 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
PREMIUMrepository. -
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
ACTIVEwhile it references deprecated images. Requests that break these rules fail withValidationException. -
-
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
statustoDEPRECATED. Don't specify it when you setstatustoACTIVE.
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
DescribeImagesorDescribeImageTags, or for a premium repository that you're entitled to,DescribeEntitledImagesorDescribeEntitledImageTags. -
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.
>>> 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/ecrpublic.py
2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 | |