Skip to content

delete_repository async

delete_repository(
    repository_name: RepositoryName,
    *,
    config_overrides: Optional[AsyncECRClientConfig] = None,
    registry_id: Optional[RegistryId] = None,
    force: Optional[ForceFlag] = None,
) -> DeleteRepositoryResponse

Deletes a repository. If the repository isn't empty, you must either delete the contents of the repository or use the force option to delete the repository and have Amazon ECR delete all of its contents on your behalf.

Parameters:

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

    The Amazon Web Services account ID associated with the registry that contains the repository to delete. If you do not specify a registry, the default registry is assumed.

  • repository_name (RepositoryName) –

    The name of the repository to delete.

  • force (Optional[ForceFlag], default: None ) –

    If true, deleting the repository force deletes the contents of the repository. If false, the repository must be empty before attempting to delete it.

Raises:

  • InvalidParameterException –

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

  • KmsException –

    The operation failed due to a KMS exception.

  • RepositoryNotEmptyException –

    The specified repository contains images. To delete a repository that contains images, you must force the deletion with the force parameter.

  • 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 force delete a repository This example force deletes a repository named ubuntu in the default registry for an account. The force parameter is required if the repository contains images.

>>> await client.delete_repository(repository_name='ubuntu', force=True)
Source code in docs_src/capo_ecr/_services/async_ecr.py
async def delete_repository(
    self,
    repository_name: "capo_ecr.types.repository_name.RepositoryName",
    *,
    config_overrides: Optional[AsyncECRClientConfig] = None,
    registry_id: Optional["capo_ecr.types.registry_id.RegistryId"] = None,
    force: Optional["capo_ecr.types.force_flag.ForceFlag"] = None,
) -> "capo_ecr.types.delete_repository_response.DeleteRepositoryResponse":
    """<p>Deletes a repository. If the repository isn't empty, you must either delete the contents of the repository or use the <code>force</code> option to delete the repository and have Amazon ECR delete all of its contents on your behalf.</p>

    Args:
        registry_id: <p>The Amazon Web Services account ID associated with the registry that contains the repository to delete. If you do not specify a registry, the default registry is assumed.</p>
        repository_name: <p>The name of the repository to delete.</p>
        force: <p>If true, deleting the repository force deletes the contents of the repository. If false, the repository must be empty before attempting to delete it.</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.kms_exception.KmsException: <p>The operation failed due to a KMS exception.</p>
        capo_ecr.errors.repository_not_empty_exception.RepositoryNotEmptyException: <p>The specified repository contains images. To delete a repository that contains images, you must force the deletion with the <code>force</code> parameter.</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 force delete a repository
        This example force deletes a repository named ubuntu in the default registry for an account. The force parameter is required if the repository contains images.

        >>> await client.delete_repository(repository_name='ubuntu', force=True)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ecr.types.delete_repository_request.DeleteRepositoryRequest]",
    ) -> AsyncOperationResponse[
        "capo_ecr.types.delete_repository_response.DeleteRepositoryResponse"
    ]:
        import capo_ecr._operations.amazon_ec2_container_registry_v20150921.delete_repository

        (
            output,
            http_response,
        ) = await capo_ecr._operations.amazon_ec2_container_registry_v20150921.delete_repository.async_delete_repository(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteRepository")
    )
    input_: capo_ecr.types.delete_repository_request.DeleteRepositoryRequest = {
        "repository_name": repository_name
    }
    if registry_id is not None:
        input_["registry_id"] = registry_id
    if force is not None:
        input_["force"] = force

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