
    :                        S r SSKJr  SSKJr  SSKJr  SSKrSSK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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SKJr  SSKJr  SSKJr  \R8                  \R:                  " \R<                  R>                  5       " S S\R@                  5      5       5       r!\R:                  " \R<                  RD                  \R<                  RF                  5       " S S\R@                  5      5       r$g)z9The Create command for Binary Authorization attestations.    )absolute_import)division)unicode_literalsN)apis)	attestors)containeranalysis)containeranalysis_apis)base)
exceptions)flags)util)
validation)
properties)	resources)
console_io)filesc                   .    \ rS rSrSr\S 5       rS rSrg)Create'   aH  Create a Binary Authorization attestation.

This command creates a Binary Authorization attestation for your project. The
attestation is created for the specified artifact (e.g. a gcr.io container
URL), associate with the specified attestor, and stored under the specified
project.

## EXAMPLES

To create an attestation in the project "my_proj" as the attestor with
resource path "projects/foo/attestors/bar", run:

    $ {command} \
        --project=my_proj \
        --artifact-url='gcr.io/example-project/example-image@sha256:abcd' \
        --attestor=projects/foo/attestors/bar \
        --signature-file=signed_artifact_attestation.pgp.sig \
        --public-key-id=AAAA0000000000000000FFFFFFFFFFFFFFFFFFFF

To create an attestation in the project "my_proj" in note "projects/foo/notes/bar",
run:

    $ {command} \
        --project=my_proj \
        --artifact-url='gcr.io/example-project/example-image@sha256:abcd' \
        --note=projects/foo/notes/bar \
        --signature-file=signed_artifact_attestation.pgp.sig \
        --public-key-id=AAAA0000000000000000FFFFFFFFFFFFFFFFFFFF
c                    [         R                  " U5        UR                  SS[        [        R
                  " S5      S9  UR                  SS[        [        R
                  " S5      S9  UR                  5       nUR                  5       n[         R                  " U[         R                  " SSSS[        R
                  " S	5      S
95        [         R                  " U[         R                  " SSS[        R
                  " S5      S95        UR                  SS[        [        R
                  " S5      S9  UR                  SSS[        R
                  " S5      S9  g )N--signature-fileTh          Path to file containing the signature to store, or `-` to read
          signature from stdin.requiredtypehelp--payload-fileF            Path to file containing the payload over which the signature was
          calculated.

          This defaults to the output of the standard payload command:

              $ {grandparent_command} create-signature-payload

          NOTE: If you sign a payload with e.g. different whitespace or
          formatting, you must explicitly provide the payload content via this
          flag.
          attestor                The Attestor whose Container Analysis Note will be used to host
              the created attestation. In order to successfully attach the
              attestation, the active gcloud account (core/account) must
              be able to read this attestor and must have the
              `containeranalysis.notes.attachOccurrence` permission for the
              Attestor's underlying Note resource (usually via the
              `containeranalysis.notes.attacher` role).	base_namer   
positionaluse_global_project_flag
group_helpnoteg            The Container Analysis Note which will be used to host
          the created attestation. In order to successfully attach the
          attestation, the active gcloud account (core/account) must have the
          `containeranalysis.notes.attachOccurrence` permission for the
          Note (usually via the `containeranalysis.notes.attacher` role).r"   r   r#   r%   --public-key-ida            The ID of the public key that will be used to verify the signature
          of the created Attestation. This ID must match the one found on the
          Attestor resource(s) which will verify this Attestation.

          For PGP keys, this must be the version 4, full 160-bit fingerprint,
          expressed as a 40 character hexadecimal string. See
          https://tools.ietf.org/html/rfc4880#section-12.2 for details.
--validate
store_trueo          Whether to validate that the Attestation can be verified by the
          provided Attestor.
        actiondefaultr   r   AddArtifactUrlFlagadd_argumentstrtextwrapdedentadd_mutually_exclusive_group	add_groupAddConceptsGetAttestorPresentationSpecGetNotePresentationSpecclsparserexclusive_groupgroups       5lib/surface/container/binauthz/attestations/create.pyArgsCreate.ArgsH   sc   	V$
__ # $	   __  	  $ 99;O%%'E	)) $) (; <	
$ 
%% (M N	
	
 __ K L	   
__  	      c           
      :   [         R                  R                  [        R                  R
                  R                  R                  SS9SS9n[        R                  " UR                  5      n[        R                  " UR                  SS9nUR                  (       a!  [        R                   " UR                  5      nO[        R"                  " U5      nUR$                  (       Ga  UR&                  R$                  R                  5       n[(        R*                  " U R-                  5       5      n[.        R0                  " U5      nUR                  U5      n	[2        R4                  " [6        R8                  UUS9n
[:        R0                  " 5       R=                  U[         R                  R?                  SURA                  U	5      RB                  0 5      UURD                  UUSU;   a  URF                  (       a  U
S	9$ S S	9$ URH                  (       aw  [:        R0                  " [J        R*                  " U R-                  5       5      5      R=                  UUR&                  RH                  R                  5       UURD                  UUS S	9$ [L        RN                  " S
5      eNT)r   zcloudresourcemanager.projects)
collection)binary)attestor_refapi_versionz containeranalysis.projects.notesvalidate)project_refnote_refartifact_urlpublic_key_id	signature	plaintextvalidation_callbackz-One of --attestor or --note must be provided.(r   REGISTRYParser   VALUEScoreprojectGetbinauthz_command_utilRemoveArtifactUrlSchemerM   r   ReadFromFileOrStdinsignature_filepayload_filer   ReadBinaryFileContentsMakeSignaturePayloadr   CONCEPTSr   GetApiVersionReleaseTrackr   Client	functoolspartialr   validate_attestationr   CreateAttestationOccurrenceParseResourceIdGetNoteAttrnoteReferencerN   rJ   r&   ca_apisr   InvalidArgumentError)selfargsrK   artifact_url_without_schemerO   payloadrH   rI   clientr   rQ   s              r@   Run
Create.Run   s?   $$**&&**D*92 + K #8"O"O# ..t/B/B4PI,,T->->?g%::
%g }}}]]++113l&&t'8'8':;k,fL)h%--

)
)#! %%'CC!%%550  *88
 3**4DMM 2 D    D   
%%


 1 1 3
4##!==%%++-2**" 	$ 	
 ++
9 rC    N	__name__
__module____qualname____firstlineno____doc__classmethodrA   rr   __static_attributes__rt   rC   r@   r   r   '   s#    < V Vp:rC   r   c                   .    \ rS rSrSr\S 5       rS rSrg)CreateWithPkixSupport   aF  Create a Binary Authorization attestation.

This command creates a Binary Authorization attestation for your project. The
attestation is created for the specified artifact (e.g. a gcr.io container
URL), associate with the specified attestor, and stored under the specified
project.

## EXAMPLES

To create an attestation in the project "my_proj" as the attestor with
resource path "projects/foo/attestors/bar", run:

    $ {command} \
        --project=my_proj \
        --artifact-url=gcr.io/example-project/example-image@sha256:abcd \
        --attestor=projects/foo/attestors/bar \
        --signature-file=signed_artifact_attestation.pgp.sig \
        --public-key-id=AAAA0000000000000000FFFFFFFFFFFFFFFFFFFF

To create an attestation in the project "my_proj" in note "projects/foo/notes/bar",
run:

    $ {command} \
        --project=my_proj \
        --artifact-url='gcr.io/example-project/example-image@sha256:abcd' \
        --note=projects/foo/notes/bar \
        --signature-file=signed_artifact_attestation.pgp.sig \
        --public-key-id=AAAA0000000000000000FFFFFFFFFFFFFFFFFFFF
c                    [         R                  " U5        UR                  SS[        [        R
                  " S5      S9  UR                  SS[        [        R
                  " S5      S9  UR                  5       nUR                  5       n[         R                  " U[         R                  " SSSS[        R
                  " S	5      S
95        [         R                  " U[         R                  " SSS[        R
                  " S5      S95        UR                  SS[        [        R
                  " S5      S9  UR                  SSS[        R
                  " S5      S9  g )Nr   Tr   r   r   Fr   r   r    r!   r&   r'   r(   r)   a'            The ID of the public key that will be used to verify the signature
          of the created Attestation. This ID must match the one found on the
          Attestor resource(s) which will verify this Attestation.

          For PKIX keys, this will be the URI-formatted `id` field of the
          associated Attestor public key.

          For PGP keys, this must be the version 4, full 160-bit fingerprint,
          expressed as a 40 character hexadecimal string. See
          https://tools.ietf.org/html/rfc4880#section-12.2 for details.r*   r+   r,   r-   r0   r;   s       r@   rA   CreateWithPkixSupport.Args   sc   	V$
__ # $	   __  	  $ 99;O%%'E	)) $) (; <	
$ 
%% (M N	
	
 __ 
K 
L	  " 
__  	  rC   c           
      >   [         R                  R                  [        R                  R
                  R                  R                  SS9SS9n[        R                  " UR                  5      n[        R                  " UR                  SS9nUR                  (       a!  [        R                   " UR                  5      nO[        R"                  " U5      nUR$                  (       Ga  UR&                  R$                  R                  5       n[(        R*                  " U R-                  5       5      n[.        R0                  " U5      nUR                  U5      n	[2        R4                  " [6        R8                  UUS9n
[:        R0                  " 5       R=                  U[         R                  R?                  SURA                  U	5      RB                  0 5      UURD                  UUSU;   a  URF                  (       a  U
S	9$ S S	9$ URH                  (       ay  UR&                  RH                  R                  5       n[:        R0                  " [J        R*                  " U R-                  5       5      5      R=                  UUUURD                  UUS S	9$ [L        RN                  " S
5      erE   rR   )rm   rn   rK   ro   rO   rp   rH   rI   rq   r   rQ   rL   s               r@   rr   CreateWithPkixSupport.RunZ  sD   $$**&&**D*92 + K #8"O"O# ..t/B/B4PI,,T->->?g%::
%g }}}]]++113l&&t'8'8':;k,fL)h%--

)
)#! %%'CC!%%550  *88
 3**4DMM 2 D    D   
##))+h%%


 1 1 3
4##!2**" 	$ 	
 ++
9 rC   rt   Nru   rt   rC   r@   r~   r~      s#    < Y Yv<rC   r~   )%rz   
__future__r   r   r   rd   r4   )googlecloudsdk.api_lib.container.binauthzr   r   r   r	   rk   googlecloudsdk.callioper
   -googlecloudsdk.command_lib.container.binauthzr   r   r   rY   r   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   DefaultUniverseOnlyReleaseTracksrb   GACreateCommandr   BETAALPHAr~   rt   rC   r@   <module>r      s    @ &  '   : ? G W ( D ? W D * ) 2 * D%%(()rT r * rj D%%**D,=,=,C,CDwD.. w EwrC   