
                         ,   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ  ej                  ej                  j                  ej                  j                  ej                  j                          G d	 d
ej"                               Zy)z,Delete an Artifact Registry container image.    )absolute_import)division)unicode_literals)base)docker_util)flags)logc                   0    e Zd ZdZdddZed        Zd Zy)Deletea@  Delete an Artifact Registry container image.

  A valid container image has the format of

    LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY-ID/IMAGE

  A valid container image that can be referenced by tag or digest, has the
  format of

    LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY-ID/IMAGE:tag
    LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY-ID/IMAGE@sha256:digest

  This command can fail for the following reasons:
    * Trying to delete an image by digest when the image is still tagged. Add
    --delete-tags to delete the digest and the tags.
    * Trying to delete an image by tag when the image has other tags. Add
    --delete-tags to delete all tags.
    * A valid repository format was not provided.
    * The specified image does not exist.
    * The active account does not have permission to delete images.
  z{description}a      To delete image `busy-box` in `us-west1` and all of its digests and tags:

        $ {command} us-west1-docker.pkg.dev/my-project/my-repository/busy-box

    To delete image digest `abcxyz` under image `busy-box`:

        $ {command} us-west1-docker.pkg.dev/my-project/my-repository/busy-box@sha256:abcxyz

    To delete image digest `abcxyz` under image `busy-box` while there're other tags associate with the digest:

        $ {command} us-west1-docker.pkg.dev/my-project/my-repository/busy-box@sha256:abcxyz --delete-tags

    To delete an image digest and its only tag `my-tag` under image `busy-box`:

        $ {command} us-west1-docker.pkg.dev/my-project/my-repository/busy-box:my-tag
    )DESCRIPTIONEXAMPLESc                     t         j                  j                  |        t        j                         j                  |        t        j
                         j                  |        y )N)r   
ASYNC_FLAGAddToParserr   GetDeleteTagsFlagGetImageRequiredArg)parsers    -lib/surface/artifacts/docker/images/delete.pyArgszDelete.ArgsK   sB    OO'	))&1	++F3    c                 T   t        j                  |      }|j                  r9t        j                  j                  dj                  |j                               yt        j                  j                  d       t        j                  |dj                  |j                               y)zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      DeleteVersion operation.
    z7Delete request issued.
Check operation [{}] for status.zDelete request issued.z&Waiting for operation [{}] to completeN)	r   DeleteDockerImageasync_r	   statusPrintformatnameWaitForOperation)selfargsops      r   Runz
Delete.RunQ   s{     
	&	&t	,B{{	jj
D
K
Kgg 
jj/0""
6==bggFHr   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r"    r   r   r   r      s2    0 	-. 4 4
Hr   r   N)r&   
__future__r   r   r   googlecloudsdk.callioper   $googlecloudsdk.command_lib.artifactsr   r   googlecloudsdk.corer	   ReleaseTracksReleaseTrackALPHABETAGACommandr   r)   r   r   <module>r4      s|    3 &  ' ( < 6 # D%%++T->->-C-C%%((*FHT\\ FH*FHr   