
    /                         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)Describea0  Get metadata for a given import job.

  Returns metadata for the given import job.

  The optional flag `--attestation-file` specifies file to write the attestation
  into. The attestation 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 import job 'strider' within the
  keyring 'fellowship' in the location 'us-central1':

    $ {command} strider --keyring=fellowship --location=us-central1

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

    $ {command} strider --keyring=fellowship --location=us-central1 \
        --attestation-file=path/to/attestation.dat
  c                     t        j                  | d       t        j                  | d       t        j                  | d       t        j                  |        y )Nz
import jobzto describe)r   AddKeyRingFlagAddLocationFlagAddPositionalImportJobArgumentAddAttestationFileFlag)parsers    'lib/surface/kms/import_jobs/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,                  _        |S # t4        j6                  $ r}t        j8                  |      d }~ww xY w)N
import_jobz import job id must be non-empty.)namez4Attestations are only available for HSM import jobs.zAThe attestation is unavailable until the import job is generated.T)	overwritebinary)cloudkms_baseGetClientInstanceGetMessagesModuler   ParseImportJobNameNamer   InvalidArgumentException&projects_locations_keyRings_importJobsGet5CloudkmsProjectsLocationsKeyRingsImportJobsGetRequestRelativeNameattestation_fileprotectionLevel	ImportJobProtectionLevelValueValuesEnumHSMkms_exceptionsArgumentErrorstateStateValueValuesEnumPENDING_GENERATIONattestationr	   WriteToFileOrStdoutcontentr
   ErrorBadFileException)selfargsclientmessagesimport_job_refr   es          r   RunzDescribe.Run=   s   ,,.F..0H--d3N //
:< <>>BBFF,,. 	G 	01J 	*"<"<99==#>((
@B B 	*"2"2h6H6H		00#1((
MO O !7!7!C-!!""**		 ) (,j$ [[ -))!,,-s   7F( (G;GGN)__name__
__module____qualname____doc__staticmethodr   r:    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>rH      s<     &  ' A ( . G 0 # *Ft## Fr   