
    *                        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  SS
KJr  SSKJr  SSKJr  SSKJr  Sr\R2                  \R4                  " \R6                  R8                  5       " S S\R:                  5      5       5       r\R2                  \R4                  " \R6                  R>                  5       " S S\5      5       5       r g)zAccess a secret version's data.    )absolute_import)division)unicode_literals)api)
exceptions)base)parser_arguments)parser_extensions)args)fmt)util)crc32ca  An incorrect data_crc32c was calculated for the provided payload. This might be a transient issue that resolves with a retry. If this is happening repeatedly open an issue with Secret Manager at https://issuetracker.google.com/issues/new?component=784854&template=1380926.c                       \ 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
)Access)   =  Access a secret version's data.

Access the data for the specified secret version.

## EXAMPLES

Access the data for version 123 of the secret 'my-secret':

  $ {command} 123 --secret=my-secret

Note: The output will be formatted as UTF-8 which can corrupt binary secrets.

To write raw bytes to a file use --out-file flag:

  $ {command} 123 --secret=my-secret --out-file=/tmp/secret

To get the raw bytes, have Google Cloud CLI print the response as
base64-encoded and decode:

  $ {command} 123 --secret=my-secret --format='get(payload.data)' | tr '_-' '/+' | base64 -d
zThe value provided for --out-file is the empty string. This can happen if you pass or pipe a variable that is undefined. Please verify that the --out-file flag is not the empty string.parserc                     [         R                  " U SSSS9  [         R                  " U SSS9  [         R                  " U 5        [        R
                  " U 5        g)zArgs is called by calliope to gather arguments for secrets versions access command.

Args:
  parser: An argparse parser that you can use to add arguments that will be
    available to this command.
	to accessTpurpose
positionalrequiredto access secretFr   hiddenNsecrets_argsAddVersionOrAliasAddLocation
AddOutFilesecrets_fmtUseSecretDatar   s    &lib/surface/secrets/versions/access.pyArgsAccess.ArgsH   sL     ""t V-?NF#f%    r   returnc                    [         R                  " U R                  5       5      nUR                  R                  R                  5       n[         R                  " US9R                  X1R                  S9nUR                  R                  bD  [        R                  " UR                  R                  UR                  R                  5      (       a  UR                  S5      (       am  UR                  (       d   [         R"                  " U R$                  5      eSUl        [(        R*                  " UR                  UR                  R                  5        U$ [,        R.                  " [0        5      e)zRun is called by calliope to implement the secret versions access command.

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

Returns:
  API call to invoke secret version access.
api_versionsecret_locationout_filedisablesecrets_apiGetApiFromTrackReleaseTrackCONCEPTSversionParseVersionsr   locationpayload
dataCrc32cr   does_data_match_checksumdataIsSpecifiedr/   calliope_exceptionsBadFileExceptionEMPTY_OUT_FILE_MESSAGEformatsecrets_utilWriteBinaryFiler   HttpException%CHECKSUM_VERIFICATION_FAILURE_MESSAGEselfr   r,   version_refr6   s        r%   Run
Access.RunW   s    --d.?.?.ABK--''--/K""{;BB]] C G !!)V-L-Lgoo88. . 
		*	%	%}}#44))+ +  $$T]]GOO4H4HIn

"
"#H
IIr(    N)__name__
__module____qualname____firstlineno____doc__rA   staticmethodr	   ArgumentInterceptorr&   r
   	Namespacer2   r8   rJ   __static_attributes__rL   r(   r%   r   r   )   sV    ,5  &#77 & &J'11 Jk6J6J Jr(   r   c                   .    \ rS rSrSr\S 5       rS rSrg)
AccessBetau   r   c                     [         R                  " U SSSS9  [         R                  " U SSS9  [         R                  " U 5        [        R
                  " U 5        g )Nr   Tr   r   Fr   r   r$   s    r%   r&   AccessBeta.Args   sJ    ""t V-?NF#f%r(   c                    [         R                  " U R                  5       5      nUR                  R                  R                  5       n[         R                  " US9R                  X1R                  S9nUR                  R                  bD  [        R                  " UR                  R                  UR                  R                  5      (       a  UR                  S5      (       am  UR                  (       d   [         R"                  " U R$                  5      eSUl        [(        R*                  " UR                  UR                  R                  5        U$ [,        R.                  " [0        5      e)Nr+   r-   r/   r0   r1   rG   s        r%   rJ   AccessBeta.Run   s   --d.?.?.ABK--''--/K""{;BB]] C G !!)V-L-Lgoo88. . 
		*	%	%}}#44))+ +  $$T]]GOO4H4HIn

"
"#H
IIr(   rL   N)	rM   rN   rO   rP   rQ   rR   r&   rJ   rU   rL   r(   r%   rW   rW   u   s!    . & &Jr(   rW   N)!rQ   
__future__r   r   r   googlecloudsdk.api_lib.secretsr   r2   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r?   r	   r
   "googlecloudsdk.command_lib.secretsr   r   r   r"   r   rC   googlecloudsdk.command_lib.utilr   rF   DefaultUniverseOnlyReleaseTracksr4   GADescribeCommandr   BETArW   rL   r(   r%   <module>rh      s    & &  ' = 2 ( E 4 5 C A C 2T & D%%(()GJT!! GJ * GJT D%%**+4J 4J , 4Jr(   