
                            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r\R*                  \R,                  " \R.                  R0                  5       " S S\R2                  5      5       5       r\R6                  \R,                  " \R.                  R8                  5       " S S\5      5       5       rg)zAccess a secret version's data.    )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.ArgsE   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_refr3   s        r"   Run
Access.RunT   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__r>   staticmethodr   ArgumentInterceptorr#   r   	Namespacer/   r5   rG   __static_attributes__rI   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)
AccessBetar   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,   r-   r.   rD   s        r"   rG   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%   rI   N)	rJ   rK   rL   rM   rN   rO   r#   rG   rR   rI   r%   r"   rT   rT   r   s!    . & &Jr%   rT   N)rN   googlecloudsdk.api_lib.secretsr   r/   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r<   r   r   "googlecloudsdk.command_lib.secretsr   r   r	   r   r
   r@   googlecloudsdk.command_lib.utilr   rC   UniverseCompatibleReleaseTracksr1   GADescribeCommandr   DefaultUniverseOnlyBETArT   rI   r%   r"   <module>re      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%   