
                             d Z ddlmZ ddlmZ ddlmZ ddl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*                   G d dej,                               Zy)z5The List command for Binary Authorization signatures.    )absolute_import)division)unicode_literalsN)apis)	attestors)containeranalysis)containeranalysis_apis)util)base)flags)	resourcesc                   2    e Zd ZdZed        Zd Zd Zd Zy)ListaS  List Binary Authorization attestations.

  This command lists Binary Authorization attestations for your
  project.  Command line flags specify which attestor and artifact to
  list the attestations for. If no attestor is specified, this lists
  all attestations in the project, which requires the
  `containeranalysis.occurrences.get` permission. If no artifact is
  specified, then this lists all URLs with associated occurrences.

  ## EXAMPLES

  List the Occurrence messages for all attestations bound to the passed
  attestor:

      $ {command} \
          --attestor=projects/foo/attestor/bar

  List the Occurrence messages for all attestations for the passed artifact-url
  bound to the passed attestor:

      $ {command} \
          --attestor=projects/foo/attestors/bar \
          --artifact-url='gcr.io/foo/example-image@sha256:abcd'
  c                     t        j                  |d       t        j                  |t        j                  ddddt	        j
                  d                   y )NF)requiredattestorz              The Attestor whose Container Analysis Note will be queried
              for attestations. Note that the caller must have the
              `containeranalysis.notes.listOccurrences` permission on the note
              being queried.)	base_namer   
positionaluse_global_project_flag
group_help)r   AddArtifactUrlFlagAddConceptsGetAttestorPresentationSpectextwrapdedent)clsparsers     3lib/surface/container/binauthz/attestations/list.pyArgsz	List.Args=   sN    	Ve4	)) $) (  !
	
    c                     d }|j                   rt        j                  |j                         }|j                  r| j	                  ||      S | j                  ||      S )N)artifact_urlbinauthz_command_utilGetImageDigestr   ListInAttestorListInProject)selfargsartifact_digests      r   RunzList.RunP   sS    O-<<T=N=NOo}}  77dO44r    c                 
   t        j                  t        j                  | j	                                     }t        j                  t        j                  | j	                                     }|j                  j                  j                         }|j                  |      }t        j                  j                  d|j                  |      j                  i       }|j!                  |||j"                  |j$                        S )Nz containeranalysis.projects.notes)note_refr)   	page_sizelimit)r   Clientr   GetApiVersionReleaseTrackr   ca_apisCONCEPTSr   ParseGetr   REGISTRYParseResourceIdGetNoteAttrnoteReferenceYieldAttestationsr-   r.   )r'   r(   r)   attestors_clientdrydock_clientattestor_refr   r,   s           r   r%   zList.ListInAttestorY   s     ''(:(:4;L;L;N(OP&--d//12N ==))//1L##L1H!!11*$$X.<<
H ++'..jj	 ,  r    c                     t        j                  t        j                  | j	                                     }|j                  d t        j                         ||j                  |j                        S )N)r,   project_refr)   r-   r.   )
r   r/   r2   r0   r1   r:   binauthz_api_utilGetProjectRefr-   r.   )r'   r(   r)   r<   s       r   r&   zList.ListInProjectn   sc    &--d//12N ++%335'..jj ,  r    N)	__name__
__module____qualname____doc__classmethodr   r*   r%   r&    r    r   r   r   "   s*    2  $5*r    r   )rE   
__future__r   r   r   r   )googlecloudsdk.api_lib.container.binauthzr   r   r   r	   r2   r
   r@   googlecloudsdk.callioper   -googlecloudsdk.command_lib.container.binauthzr   r#   googlecloudsdk.corer   DefaultUniverseOnlyListCommandr   rG   r    r   <module>rO      s[    < &  '  : ? G W O ( ? W ) V4 V Vr    