
                            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
 dd	lmZ dd
lmZ ddlmZ  ej                  ej                   j"                        ej$                   G d dej&                                      Zy)z4Implements the command to list SBOM file references.    )absolute_import)division)unicode_literals)base)endpoint_util)flags)sbom_printer)	sbom_util)util)resource_printerc                   0    e Zd ZdZdddZed        Zd Zy)ListzList SBOM file references.z{description}a            To list SBOM file references:

          $ {command}

          To list SBOM file references related to the image with the tag "us-east1-docker.pkg.dev/project/repo/my-image:1.0":

          $ {command} --resource="us-east1-docker.pkg.dev/project/repo/my-image:1.0"

          To list SBOM file references related to the image with the digest "us-east1-docker.pkg.dev/project/repo/my-image@sha256:88b205d7995332e10e836514fbfd59ecaf8976fc15060cd66e85cdcebe7fb356":

          $ {command} --resource="us-east1-docker.pkg.dev/project/repo/my-image@sha256:88b205d7995332e10e836514fbfd59ecaf8976fc15060cd66e85cdcebe7fb356"

          To list SBOM file references related to the images with the resource path prefix "us-east1-docker.pkg.dev/project/repo":

          $ {command} --resource-prefix="us-east1-docker.pkg.dev/project/repo"

          To list SBOM file references generated when the images were pushed to Artifact Registry and related to the installed package dependency "perl":

          $ {command} --dependency="perl"

          )DESCRIPTIONEXAMPLESc                    t        j                  t        j                  t        j                  d       | j
                  j                  t        j                         t        j                  j                  | d       t        j                  j                  |        t        j                         j                  |        | j                  d      }|j!                  ddd       |j!                  d	dd
       |j!                  ddd       y)z[Set up arguments for this command.

    Args:
      parser: An argparse.ArgumentPaser.
    T)hiddenzocc.create_time)mutexz--dependencyFzList SBOM file references generated when the images were pushed to Artifact Registry and related to the installed package dependency. See https://cloud.google.com/container-analysis/docs/scanning-types for supported packages.)requiredhelpz
--resourcez<List SBOM file references related to the image resource uri.z--resource-prefixzTList SBOM file references related to the resource uri with the resource path prefix.N)r   RegisterFormatterr	   SBOM_PRINTER_FORMATSbomPrinterdisplay_info	AddFormatr   SORT_BY_FLAG
SetDefaultURI_FLAGRemoveFromParserr   GetOptionalAALocationFlagAddToParser	add_groupadd_argument)parsergroups     "lib/surface/artifacts/sbom/list.pyArgsz	List.Args=   s     &&((   !!,"B"BC  ):;MM""6*	##%11&94(E	'	  
 
K  
 
%	      c                    |j                   }t        j                  |      5  |:t        j                  |      }t        j
                  ||j                         |_        t        j                  |      cddd       S # 1 sw Y   yxY w)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 SBOM references.
    N)	locationr   
WithRegionr   
GetProject	GetParentprojectr
   ListSbomReferences)selfargsr)   r-   s       r%   RunzList.Runh   s_     }}H		!	!(	+		//$'~~gt}}=))$/	 
,	+	+s   AA==BN)__name__
__module____qualname____doc__detailed_helpstaticmethodr&   r1    r'   r%   r   r      s2     # %-4 ( (T0r'   r   N)r5   
__future__r   r   r   googlecloudsdk.callioper   $googlecloudsdk.command_lib.artifactsr   r   r	   r
   r   googlecloudsdk.core.resourcer   ReleaseTracksReleaseTrackGADefaultUniverseOnlyListCommandr   r8   r'   r%   <module>rB      ss    ; &  ' ( > 6 = : 5 9 D%%(()W04 W0  *W0r'   