
    z                         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Z
ej                   G d	 d
ej                               Zy)z List Artifact Registry versions.    )absolute_import)division)unicode_literals)base)flags)version_utilz    table(
         name.basename().sub("%5E", "^"):label=VERSION,
         description,
         createTime.date(tz=LOCAL),
         updateTime.date(tz=LOCAL),
         metadata.imageSizeBytes:label=SIZE,
         annotations
       )c                   0    e Zd ZdZdddZed        Zd Zy)ListzList Artifact Registry package versions.

  List all Artifact Registry versions in the specified package.

  To specify the maximum number of versions to list, use the --limit flag.
  z{description}ar  
      The following command lists a maximum of five packages versions:

          $ {command} --limit=5

      To list versions of package `my_pkg` with name as `1.0-SNAPSHOT`:

          $ {command} --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/1.0-SNAPSHOT"'

      To list versions of package `my_pkg` with a given partial name, use `*` to match any character in name:

          $ {command} --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/1.0*"'

          $ {command} --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/*SNAPSHOT"'

      To list versions of package `my_pkg` that have annotations:

          $ {command} --package=my_pkg --filter=annotations:*

      To list versions of package `my_pkg` with annotations pair as [annotation_key: annotation_value]:

          $ {command} --package=my_pkg --filter='annotations.annotation_key:annotation_value'

      To list versions of package `my_pkg` with annotations containing key as `my_key`:

          $ {command} --package=my_pkg --filter=annotations.my_key

          If the key or value contains special characters, such as `my.key` and `my.value`, backtick("`") is required:

          $ {command} --filter='annotations.`my.key`'

          $ {command} --filter='annotations.`my.key`:`my.value`'

      To list versions of package `my_pkg` with given partial annotation key or value, use `*` to match any character:

          $ {command} --filter='annotations.*key:`*.value`'

      To list versions of package `my_pkg` ordered by create_time:

        $ {command} --package=my_pkg --sort-by=create_time

      To list versions of package `my_pkg` ordered by update_time reversely:

        $ {command} --package=my_pkg --sort-by=~update_time
  )DESCRIPTIONEXAMPLESc                     | j                   j                  t               t        j                  j                  |        t        j                         j                  |        | j                  ddd       y )Nz	--packageTzcList all versions in a specified artifact, such as a container
        image or a language package.)requiredhelp)
display_info	AddFormatDEFAULT_LIST_FORMATr   URI_FLAGRemoveFromParserr   GetRepoFlagAddToParseradd_argument)parsers    &lib/surface/artifacts/versions/list.pyArgsz	List.Args`   s^    
!!"56MM""6*	##F+
(      c                 @    fdt        j                        D        S )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:
      A list of package versions.
    c              3   J   K   | ]  }t        j                  |        y w)N)r   ConvertFingerprint).0vargss     r   	<genexpr>zList.Run.<locals>.<genexpr>v   s&      0A 	''400s    #)r   ListVersions)selfr!   s    `r   RunzList.Runl   s     **40 r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r%    r   r   r
   r
   $   s2     -	2-h 	 	r   r
   N)r)   
__future__r   r   r   googlecloudsdk.callioper   $googlecloudsdk.command_lib.artifactsr   r   r   DefaultUniverseOnlyListCommandr
   r,   r   r   <module>r2      sN    ' &  ' ( 6 =  T4 T Tr   