
                         n    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  Sr	Sr
S	rS
r\r " S S\5      rg)z7Helper functions for interacting with the binauthz API.    )absolute_import)division)unicode_literals)
list_pager)apiscontaineranalysisv1alpha1v1beta1v1c                   B    \ rS rSrSrSS jr     S	S jr SS jrSrg)
Client    z;A client to access containeranalysis for binauthz purposes.Nc                     U=(       d    [         U l        [        R                  " [        U R                  5      U l        [        R                  " [        U R                  5      U l        g)zcCreates a ContainerAnalysisClient.

Args:
  api_version: The containeranalysis API version to use.
N)DEFAULT_VERSIONapi_versionr   GetClientInstanceAPI_NAMEclientGetMessagesModulemessages)selfr   s     Blib/googlecloudsdk/api_lib/container/binauthz/containeranalysis.py__init__Client.__init__#   sE     #5oD((43C3CDDK**8T5E5EFDM    c           	   #     ^ #    Ub  SR                  U5      OSnUc?  T R                  R                  nT R                  R	                  UR                  5       US9nO>T R                  R                  nT R                  R                  UR                  5       US9n[        R                  " UUSU=(       d    SSUS	9n	U 4S
 jn
U	 H  nU
" U5      (       d  M  Uv   M     g7f)a   Yields occurrences associated with a given attestor Note or Project.

Args:
  note_ref: The Note reference that will be queried for attached
    occurrences. If None, then all occurrences from the given project will
    be listed. (containeranalysis.projects.notes Resource)
  project_ref: The Project referenece that will be queried for occurrences
    if note_ref is None.
  artifact_digest: Digest of the artifact for which to fetch occurrences. If
    None, then all occurrences attached to the AA Note are returned.
  page_size: The number of attestations to retrieve per request. (If None,
    use the default page size.)
  limit: The maxium number of attestations to retrieve. (If None,
    unlimited.)

Yields:
  Occurrences bound to `note_ref` with matching `artifact_digest` (if
  passed).
Nzhas_suffix(resourceUrl, "{}") )parentfilter)namer   occurrencesd   pageSize)servicerequestfield
batch_sizebatch_size_attributelimitc                 x   > U R                   TR                  R                  R                  R                  :w  a  gg)NFT)kindr   
OccurrenceKindValueValuesEnumATTESTATION)
occurrencer   s    r   MatchesFilter/Client.YieldAttestations.<locals>.MatchesFilterg   s1    
//]]%%99EEF r   )
formatr   projects_occurrencesr   /ContaineranalysisProjectsOccurrencesListRequestRelativeNameprojects_notes_occurrences4ContaineranalysisProjectsNotesOccurrencesListRequestr   YieldFromList)r   note_refproject_refartifact_digest	page_sizer)   artifact_filterr$   r%   occurrence_iterr0   r/   s   `           r   YieldAttestationsClient.YieldAttestations.   s     : & 	(..? 
 00gMM))+O N g 66g
--
L
L((*? M   !..#'O &
	z	"	" &s   CC	Cc                    U R                   [        :X  d   eU R                  R                  UU R                  R	                  XES9/S9nU R                  R                  U R                  R
                  R                  R                  UUR                  5       US9n	U R                  R                  UR                  5       U	S9n
Ub  U" U	5        U R                  R                  R                  U
5      $ )a  Creates an Occurrence referencing given URL and Note.

This only supports the AttestationOccurrence-type Occurrence, currently only
present in the v1 version of the API.

Args:
  note_ref: The Note reference that the created Occurrence will be bound to.
    (containeranalysis.projects.notes Resource)
  project_ref: The project ref where the Occurrence will be created.
    (cloudresourcemanager.projects Resource)
  artifact_url: URL of artifact to which the signature is associated.
    (string)
  public_key_id: The URI of the public key that will be used to verify the
    signature. (string)
  signature: The content artifact's signature as generated by the specified
    key's signing operation. (string)
  plaintext: The content that was signed. (string)
  validation_callback: If provided, a function to validate the Occurrence
    prior to creation. (Callable[[Occurrence], None])

Returns:
  Created Occurrence.
)publicKeyId	signature)serializedPayload
signatures)r+   resourceUrinoteNameattestation)r   r/   )r   V1r   AttestationOccurrence	Signaturer,   r-   r.   r5   1ContaineranalysisProjectsOccurrencesCreateRequestr   r3   Create)r   r9   r:   artifact_urlpublic_key_idrC   	plaintextvalidation_callbackrH   r/   r%   s              r   CreateAttestationOccurrence"Client.CreateAttestationOccurrences   s    B r!!!--55#MM##) $ 
 6 K ))]]%%99EE &&(	 * J mmMM'') N G
 &*%;;++227;;r   )r   r   r   )N)NNNNN)	__name__
__module____qualname____firstlineno____doc__r   r?   rR   __static_attributes__ r   r   r   r       s-    C	G CZ 8<r   r   N)rX   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   r   	V1_ALPHA1V1_BETA1rI   r   objectr   rZ   r   r   <module>ra      s@    > &  ' ' ,		K<V K<r   