
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
m	Z ddl
mZ ddlmZ dd	lmZ  G d
 dej"                        Zy)zDescribe a version.    )absolute_import)division)unicode_literals)base)
exceptions)flags)log)filesc                   &    e Zd ZdZed        Zd Zy)DescribeaB  Get metadata for a given version.

  Returns metadata for the given version.

  The optional flag `attestation-file` specifies file to write the attestation
  object into. The attestation object enables the user to verify the integrity
  and provenance of the key. See https://cloud.google.com/kms/docs/attest-key
  for more information about attestations.

  ## EXAMPLES

  The following command returns metadata for version 2 within key `frodo`
  within the keyring `fellowship` in the location `us-east1`:

    $ {command} 2 --key=frodo --keyring=fellowship --location=us-east1

  For key versions with protection level `HSM`, use the `--attestation-file`
  flag to save the attestation to a local file.

    $ {command} 2 --key=frodo --keyring=fellowship --location=us-east1 \
        --attestation-file=path/to/attestation.dat
  c                 Z    t        j                  | d       t        j                  |        y )Nzto describe)r   AddKeyVersionResourceArgumentAddAttestationFileFlag)parsers    )lib/surface/kms/keys/versions/describe.pyArgszDescribe.Args6   s     	''>	  (    c                    t        j                         }t        j                         }t        j                  |      }|j                         st        j                  dd      |j                  j                  |j                  |j                                     }|j                  rB|j                  |j                  j                  j                   k7  rt#        j$                  d      |j                  rB|j&                  |j                  j(                  j*                  k(  rt#        j$                  d      |j                  rD|j,                  8	 t/        j0                  |j                  |j,                  j2                  dd       |j,                  "d |j,                  _        d |j,                  _        |S # t4        j6                  $ r}t        j8                  |      d }~ww xY w)Nversionzversion id must be non-empty.)namez5Attestations are only available for HSM key versions.z>The attestation is unavailable until the version is generated.T)	overwritebinary)cloudkms_baseGetClientInstanceGetMessagesModuler   ParseCryptoKeyVersionNameNamer   InvalidArgumentException8projects_locations_keyRings_cryptoKeys_cryptoKeyVersionsGetFCloudkmsProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetRequestRelativeNameattestation_fileprotectionLevelCryptoKeyVersionProtectionLevelValueValuesEnumHSMkms_exceptionsArgumentErrorstateStateValueValuesEnumPENDING_GENERATIONattestationr	   WriteToFileOrStdoutcontentr
   ErrorBadFileException
certChains)selfargsclientmessagesversion_refr   es          r   RunzDescribe.Run;   s   ,,.F..0H11$7K//
46 6MMQQNN))+ 	O 	-.G 	'"9"9!!@@DD#E((
AC C 	'--!!66II#J((
JL L !4!4!@-!!''		 & %)g! (,g$N [[ -))!,,-s   7F9 9G&G!!G&N)__name__
__module____qualname____doc__staticmethodr   r9    r   r   r   r      s     . ) )+r   r   N)r=   
__future__r   r   r   googlecloudsdk.api_lib.cloudkmsr   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.kmsr(   r   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   DescribeCommandr   r?   r   r   <module>rG      s<     &  ' A ( . G 0 # *Ht## Hr   