
                             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                   " S
 S\R                   5      5       rg)z'Get the public key for a given version.    )absolute_import)division)unicode_literals)base)
exceptions)flags)maps)logc                   .    \ rS rSrSr\S 5       rS rSrg)GetPublicKey   a  Get the public key for a given version.

Returns the public key of the given asymmetric key version in the specified format.

The optional flag `output-file` indicates the path to store the public key.
If not specified, the public key will be printed to stdout.

The optional flag `public-key-format` indicates the format in which the
public key will be returned. For the NIST PQC algorithms, this must be
specified and set to `nist-pqc`. For kem-xwing this must be specified and set to
`xwing-raw-bytes`. For all other algorithms, this flag is
optional and can be either `pem` or `der`; the default value is `pem`.
See "Retrieve a public key" in the Cloud KMS
documentation (https://cloud.google.com/kms/help/get-public-key) for more
information about the supported formats.

## EXAMPLES

The following command saves the public key for CryptoKey `frodo` Version 2
to '/tmp/my/public_key.file':

  $ {command} 2 \
  --key=frodo \
  --keyring=fellowship \
  --location=us-east1 \
  --public-key-format=pem \
  --output-file=/tmp/my/public_key.file
c                     [         R                  " U S5        [         R                  " U S5        [         R                  " U 5        g )Nzto get public keyzto store public key)r   AddKeyVersionResourceArgumentAddOutputFileFlagAddPublicKeyFormatFlag)parsers    /lib/surface/kms/keys/versions/get_public_key.pyArgsGetPublicKey.Args<   s2    	''0CD	F$9:	  (    c                    [         R                  " 5       n[         R                  " 5       n[        R                  " U5      nUR                  5       (       d  [        R                  " SS5      eUR                  UR                  5       S9nUR                  (       aU  UR                  S;  a  [        R                  " SS5      e[        R                  R                  UR                  5      Ul        UR                  R!                  U5      nUR                  S;   n["        R$                  " UR&                  (       a  UR&                  OSUR(                  (       a  UR(                  OUR*                  R,                  S	US	S
9  g )Nversionzversion id must be non-empty.)name)pemdernist-pqcxwing-raw-bytesz--public-key-formatziInvalid value for public key format. Supported values are "der", "pem", "xwing-raw-bytes" and "nist-pqc".)r   r   r   -T)	overwritebinaryprivate)cloudkms_baseGetClientInstanceGetMessagesModuler   ParseCryptoKeyVersionNameNamer   InvalidArgumentExceptionOCloudkmsProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetPublicKeyRequestRelativeNamepublic_key_formatr	   PUBLIC_KEY_FORMAT_MAPPERGetEnumForChoicepublicKeyFormat8projects_locations_keyRings_cryptoKeys_cryptoKeyVersionsr   r
   WriteToFileOrStdoutoutput_filer   	publicKeydata)selfargsclientmessagesversion_refreqrespwrite_binary_files           r   RunGetPublicKey.RunB   sQ   ,,.F..0H11$7K//
4  
b
b%%' c C 			 ( 
 11!8
 	

 !99JJ

 
 c JJWWD .. 3 
  ,,#HH$.."5"5 r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r;   __static_attributes__r=   r   r   r   r      s     : ) )
,r   r   N)rB   
__future__r   r   r   googlecloudsdk.api_lib.cloudkmsr   r"   googlecloudsdk.callioper   googlecloudsdk.command_lib.kmsr   r	   googlecloudsdk.corer
   UniverseCompatibleDescribeCommandr   r=   r   r   <module>rL      sO    . &  ' A ( . 0 / # P4'' P Pr   