Deletes a list of specified images within a repository. 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 image's digest in your request.
Parameters:
-
registry_id
(Optional[RegistryId], default:
None
)
–
The Amazon Web Services account ID associated with the registry that contains the image to delete. If you do not specify a registry, the default registry is assumed.
-
repository_name
(RepositoryName)
–
The repository that contains the image to delete.
-
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:
-
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 delete multiple images
This example deletes images with the tags precise and trusty in a repository called ubuntu in the default registry for an account.
>>> await client.batch_delete_image(repository_name='ubuntu', image_ids=[{'imageTag': 'precise'}])
Source code in docs_src/capo_ecr/_services/async_ecr.py
| async def batch_delete_image(
self,
repository_name: "capo_ecr.types.repository_name.RepositoryName",
image_ids: "capo_ecr.types.image_identifier_list.ImageIdentifierList",
*,
config_overrides: Optional[AsyncECRClientConfig] = None,
registry_id: Optional["capo_ecr.types.registry_id.RegistryId"] = None,
) -> "capo_ecr.types.batch_delete_image_response.BatchDeleteImageResponse":
"""<p>Deletes a list of specified images within a repository. 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 image's digest in your request.</p>
Args:
registry_id: <p>The Amazon Web Services account ID associated with the registry that contains the image to delete. If you do not specify a registry, the default registry is assumed.</p>
repository_name: <p>The repository that contains the image to delete.</p>
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.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 delete multiple images
This example deletes images with the tags precise and trusty in a repository called ubuntu in the default registry for an account.
>>> await client.batch_delete_image(repository_name='ubuntu', image_ids=[{'imageTag': 'precise'}])
"""
async def _handler(
req: "AsyncOperationRequest[capo_ecr.types.batch_delete_image_request.BatchDeleteImageRequest]",
) -> AsyncOperationResponse[
"capo_ecr.types.batch_delete_image_response.BatchDeleteImageResponse"
]:
import capo_ecr._operations.amazon_ec2_container_registry_v20150921.batch_delete_image
(
output,
http_response,
) = await capo_ecr._operations.amazon_ec2_container_registry_v20150921.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.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
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|