Deletes a list of specified images that are within a repository in a public registry. Images are specified with either an imageTag or imageDigest.
You can remove a tag from an image by specifying the image's tag in your request. When you remove the last tag from an image, the image is deleted from your repository.
You can completely delete an image (and all of its tags) by specifying the digest of the image in your request.
Parameters:
-
registry_id
(Optional[RegistryIdOrAlias], default:
None
)
–
The Amazon Web Services account ID, or registry alias, that's associated with the registry that contains the image to delete. If you do not specify a registry, the default public registry is assumed.
-
repository_name
(RepositoryName)
–
The repository in a public registry that contains the image to delete.
-
repository_type
(Optional[RepositoryType], default:
None
)
–
The type of the repository. If you don't specify a type, Amazon ECR uses FREE. Valid values:
-
image_ids
(ImageIdentifierList)
–
A list of image ID references that correspond to images to delete. The format of the imageIds reference is imageTag=tag or imageDigest=digest.
Raises:
-
DeletionNotAllowedException
–
You can't delete this image directly because the premium repository is no longer in the DRAFT state. To remove the image, use SetImageStatus to deprecate it.
-
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.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_ecr_public/_services/async_ecrpublic.py
| async def batch_delete_image(
self,
repository_name: "capo_ecr_public.types.repository_name.RepositoryName",
image_ids: "capo_ecr_public.types.image_identifier_list.ImageIdentifierList",
*,
config_overrides: Optional[AsyncECRPUBLICClientConfig] = None,
registry_id: Optional[
"capo_ecr_public.types.registry_id_or_alias.RegistryIdOrAlias"
] = None,
repository_type: Optional[
"capo_ecr_public.types.repository_type.RepositoryType"
] = None,
) -> "capo_ecr_public.types.batch_delete_image_response.BatchDeleteImageResponse":
"""<p>Deletes a list of specified images that are within a repository in a public registry. Images are specified with either an <code>imageTag</code> or <code>imageDigest</code>.</p> <p>You can remove a tag from an image by specifying the image's tag in your request. When you remove the last tag from an image, the image is deleted from your repository.</p> <p>You can completely delete an image (and all of its tags) by specifying the digest of the image in your request.</p>
Args:
registry_id: <p>The Amazon Web Services account ID, or registry alias, that's associated with the registry that contains the image to delete. If you do not specify a registry, the default public registry is assumed.</p>
repository_name: <p>The repository in a public registry that contains the image to delete.</p>
repository_type: <p>The type of the repository. If you don't specify a type, Amazon ECR uses <code>FREE</code>. Valid values:</p> <ul> <li> <p> <code>FREE</code>: A free repository.</p> </li> <li> <p> <code>PREMIUM</code>: A premium repository that holds paid content.</p> </li> </ul>
image_ids: <p>A list of image ID references that correspond to images to delete. The format of the <code>imageIds</code> reference is <code>imageTag=tag</code> or <code>imageDigest=digest</code>.</p>
Raises:
capo_ecr_public.errors.deletion_not_allowed_exception.DeletionNotAllowedException: <p>You can't delete this image directly because the premium repository is no longer in the <code>DRAFT</code> state. To remove the image, use <code>SetImageStatus</code> to deprecate it.</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.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_ecr_public.types.batch_delete_image_request.BatchDeleteImageRequest]",
) -> AsyncOperationResponse[
"capo_ecr_public.types.batch_delete_image_response.BatchDeleteImageResponse"
]:
import capo_ecr_public._operations.spencer_frontend_service.batch_delete_image
(
output,
http_response,
) = await capo_ecr_public._operations.spencer_frontend_service.batch_delete_image.async_batch_delete_image(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("BatchDeleteImage")
)
input_: capo_ecr_public.types.batch_delete_image_request.BatchDeleteImageRequest = {
"repository_name": repository_name,
"image_ids": image_ids,
}
if registry_id is not None:
input_["registry_id"] = registry_id
if repository_type is not None:
input_["repository_type"] = repository_type
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|