
    P                     ^   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0rS r\R&                  " \R(                  R*                  \R(                  R,                  \R(                  R.                  5       " S S\R0                  5      5       rg)z7Get a PEM-format certificate chain for a given version.    )absolute_import)division)unicode_literals)base)
exceptions)flags)log)filesEXAMPLESa          The following command saves the Cavium certificate chain for
        CryptoKey ``frodo'' Version 2 to ``/tmp/my/cavium.pem'':

          $ {command} 2 --key=frodo --keyring=fellowship --location=us-east1 --certificate-chain-type=cavium --output-file=/tmp/my/cavium.pem
        c                    US:X  a  SR                  U R                  5      $ US:X  a  SR                  U R                  5      $ US:X  a  SR                  U R                  5      $ US:X  a5  SR                  U R                  U R                  -   U R                  -   5      $ [        R
                  " SR                  U5      5      e)a]  Returns the specified certificate chain(s) from a CertChains object.

Args:
  chains: a KeyOperationAttestation.CertChains object.
  chain_type: a string specifying the chain(s) to retrieve.

Returns:
  A string containing the PEM-encoded certificate chain(s).

Raises:
  exceptions.InvalidArgumentException if chain_type is not a valid chain type.
cavium zgoogle-cardzgoogle-partitionallz{} is not a valid chain type.)joincaviumCertsgoogleCardCertsgooglePartitionCertsr   InvalidArgumentExceptionformat)chains
chain_types     6lib/surface/kms/keys/versions/get_certificate_chain.py_GetCertificateChainPemr   '   s     8776%%&&]"776))**''776..//U776%%(C(CC))* + +++%,,Z8	: :    c                   2    \ rS rSrSr\r\S 5       rS r	Sr
g)GetCertificateChainA   zGet a certificate chain for a given version.

Returns the PEM-format certificate chain for the specified key version.
The optional flag `output-file` indicates the path to store the PEM. If not
specified, the PEM will be printed to stdout.
c                     [         R                  " U S5        [         R                  " U 5        [         R                  " U S5        g )Nz'from which to get the certificate chainzto store PEM)r   AddKeyVersionResourceArgumentAddCertificateChainFlagAddOutputFileFlag)parsers    r   ArgsGetCertificateChain.ArgsM   s4    	''9;	!!&)	FN3r   c                 z   [         R                  " 5       n[         R                  " 5       n[        R                  " U5      nUR                  5       (       d  [        R                  " SS5      eUR                  nUR                  UR                  UR                  5       S95      nUR                  UR                  R                  R                  :w  a  [         R"                  " S5      eUR$                  UR                  R&                  R(                  :X  a  [         R"                  " S5      e [*        R,                  " UR.                  (       a  UR.                  OS[1        UR2                  R4                  UR6                  5      SSS	9  g ! [8        R:                   a  n[        R<                  " U5      eS nAff = f)
Nversionzversion id must be non-empty.)namez;Certificate chains are only available for HSM key versions.zBCertificate chains are unavailable until the version is generated.-TF)	overwritebinary)cloudkms_baseGetClientInstanceGetMessagesModuler   ParseCryptoKeyVersionNameNamer   r   8projects_locations_keyRings_cryptoKeys_cryptoKeyVersionsGetFCloudkmsProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetRequestRelativeNameprotectionLevelCryptoKeyVersionProtectionLevelValueValuesEnumHSMkms_exceptionsArgumentErrorstateStateValueValuesEnumPENDING_GENERATIONr	   WriteToFileOrStdoutoutput_filer   attestation
certChainscertificate_chain_typer
   ErrorBadFileException)selfargsclientmessagesversion_refversionsr&   es           r   RunGetCertificateChain.RunT   sy   ,,.F..0H11$7K//
46 6NNHll	O	O))+ 
P 
-.G 	!!@@DD	E((
GI I!!66II	J((
NP P+	"..$

C
!'"5"5"@"@"&"="=? ;; +''**+s   .AF F:F55F: N)__name__
__module____qualname____firstlineno____doc__DETAILED_HELPdetailed_helpstaticmethodr#   rK   __static_attributes__rM   r   r   r   r   A   s%      -4 4+r   r   N)rR   
__future__r   r   r   googlecloudsdk.api_lib.cloudkmsr   r+   googlecloudsdk.callioper   googlecloudsdk.command_lib.kmsr8   r   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   rS   r   ReleaseTracksReleaseTrackALPHABETAGADescribeCommandr   rM   r   r   <module>rc      s    > &  ' A ( . G 0 # * 	:4 D%%++T->->-C-C%%((*-+$.. -+*-+r   