
                            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SK	J
r  SSK	Jr  SS	K	Jr  SS
KJr  \R$                  \R&                  " \R(                  R*                  5       " S S\R,                  5      5       5       r\R0                  \R&                  " \R(                  R2                  5       " S S\5      5       5       rg)z*Enable the version of the provided secret.    )api)base)
exceptions)parser_arguments)parser_extensions)args)log)util)crc32cc                       \ rS rSrSrSr\S\R                  4S j5       r	S\
R                  S\R                  4S jrS	rg
)Create     Create a new version of an existing secret.

Create a new version of an existing secret with the provided data. The
command will return an error if no such secret exists.

## EXAMPLES

Create a new version of an existing secret named 'my-secret' with secret data
"s3cr3t":

  $ printf "s3cr3t" | {command} my-secret --data-file=-

Create a new version of an existing secret named 'my-secret' with secret data
"s3cr3t" using PowerShell (Note: PowerShell will add a newline to the
resulting secret):

  $ Write-Output "s3cr3t" | {command} my-secret --data-file=-

Create a new version of an existing secret named 'my-secret' with secret data
from a file:

  $ {command} my-secret --data-file=/tmp/secret
zThe value provided for --data-file is the empty string. This can happen if you pass or pipe a variable that is undefined. Please verify that the --data-file flag is not the empty string.parserc                     [         R                  " U SSSS9  [         R                  " U SSS9  [         R                  " U SS9  g)	zArgs is called by calliope to gather arguments for secrets versions add command.

Args:
  parser: An argparse parser that you can use to add arguments that will be
    available to this command.
	to createTpurpose
positionalrequiredto create secret versionFr   hiddenr   Nsecrets_args	AddSecretAddLocationAddDataFiler   s    #lib/surface/secrets/versions/add.pyArgsCreate.Args=   sE     t 25 Vd3    r   returnc                 (   [         R                  " U R                  5       5      nUR                  R                  R                  5       nUR                  SLn[        R                  " UR                  5      nUR                  S:X  a   [        R                  " U R                  5      e[        R                  " U5      n[         R                  " US9R!                  UU[        R"                  " U5      UR                  S9nU(       a!  [$        R&                  " UR(                  5      nO [$        R*                  " UR(                  5      n[,        R.                  " 5       R1                  U5        UR2                  (       d  [        R4                  " S5      eU$ )zRun is called by calliope to implement the secret versions add command.

Args:
  args: an argparse namespace, all the arguments that were provided to this
    command invocation.

Returns:
  API call to invoke secret version add.
N api_versionsecret_locationVersion created but payload data corruption may have occurred, please destroy the created version, and retry. See also https://cloud.google.com/secret-manager/docs/data-integrity.secrets_apiGetApiFromTrackReleaseTrackCONCEPTSsecretParselocationsecrets_utilReadFileOrStdin	data_filer   BadFileExceptionEMPTY_DATA_FILE_MESSAGEr   
get_crc32cSecrets
AddVersionget_checksumr   ParseRegionalVersionRefnameParseVersionRefsecrets_logVersionsCreatedclientSpecifiedPayloadChecksumHttpException	selfr   r)   
secret_refis_regionaldatadata_crc32cversionversion_refs	            r!   Run
Create.RunM   s5    --d.?.?.ABK%%++-J--t+K''7D ~~''(D(DEE##D)K!!k:EEK(	 F G  88Fk 00>k"";/11$$I 
 Nr$    N)__name__
__module____qualname____firstlineno____doc__r9   staticmethodr   ArgumentInterceptorr"   r   	Namespacer.   rB   rN   __static_attributes__rP   r$   r!   r   r      sS    26 
 4#77 4 4&'11 &k6J6J &r$   r   c                   .    \ rS rSrSr\S 5       rS rSrg)
CreateBetav   r   c                     [         R                  " U SSSS9  [         R                  " U SSS9  [         R                  " U SS9  g )Nr   Tr   r   Fr   r   r   r    s    r!   r"   CreateBeta.Args   sC    t 25 Vd3r$   c                 (   [         R                  " U R                  5       5      nUR                  R                  R                  5       nUR                  S Ln[        R                  " UR                  5      nUR                  S:X  a   [        R                  " U R                  5      e[        R                  " U5      n[         R                  " US9R!                  UU[        R"                  " U5      UR                  S9nU(       a!  [$        R&                  " UR(                  5      nO [$        R*                  " UR(                  5      n[,        R.                  " 5       R1                  U5        UR2                  (       d  [        R4                  " S5      eU$ )Nr'   r(   r*   r,   r-   rF   s	            r!   rN   CreateBeta.Run   s5   --d.?.?.ABK%%++-J--t+K''7D ~~''(D(DEE##D)K!!k:EEK(	 F G  88Fk 00>k"";/11$$IJ J Nr$   rP   N)	rQ   rR   rS   rT   rU   rV   r"   rN   rY   rP   r$   r!   r[   r[   v   s     0 4 4r$   r[   N)rU   googlecloudsdk.api_lib.secretsr   r.   googlecloudsdk.callioper   r   r   r   "googlecloudsdk.command_lib.secretsr   r   r	   rA   r
   r5   googlecloudsdk.command_lib.utilr   UniverseCompatibleReleaseTracksr0   GACreateCommandr   DefaultUniverseOnlyBETAr[   rP   r$   r!   <module>rk      s    1 > ( . 4 5 C A C 2 D%%(()TT T * Tn D%%**+? ? , ?r$   