
                             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0r\R"                  " \R$                  R&                  5       " S S\R(                  5      5       rg)z+Export a pem-encoded certificate to a file.    )absolute_import)division)unicode_literals)base)	pem_utils)resource_args)log)filesEXAMPLESa          To export a single pem-encoded certificate to a file, run the following:

          $ {command} my-cert --issuer=my-ca --issuer-location=us-west1 --output-file=cert.pem

        To export a pem-encoded certificate along with its issuing chain in the
        same file, run the following:

          $ {command} my-cert --issuer=my-ca --issuer-location=us-west1 --include-chain --output-file=chain.pem

        You can omit the --issuer-location flag in both of the above examples if
        you've already set the privateca/location property. For example:

          $ {top_command} config set privateca/location us-west1

          # The following is equivalent to the first example above.
          $ {command} my-cert --issuer=my-ca --output-file=cert.pem

          # The following is equivalent to the second example above.
          $ {command} my-cert --issuer=my-ca --include-chain --output-file=chain.pem
        c                   .    \ rS rSrSr\S 5       rS rSrg)Export7   a  Export a pem-encoded certificate to a file.

## EXAMPLES

To export a single pem-encoded certificate to a file, run the following:

  $ {command} my-cert --issuer-pool=my-pool --issuer-location=us-west1 \
    --output-file=cert.pem

To export a pem-encoded certificate along with its issuing chain in the
same file, run the following:

$ {command} my-cert --issuer-pool=my-pool --issuer-location=us-west1 \
  --include-chain \
  --output-file=chain.pem

You can omit the --issuer-location flag in both of the above examples if
you've already set the privateca/location property. For example:

$ {top_command} config set privateca/location us-west1

# The following is equivalent to the first example above.
$ {command} my-cert --issuer-pool=my-pool --output-file=cert.pem

# The following is equivalent to the second example above.
$ {command} my-cert --issuer-pool=my-pool --include-chain \
  --output-file=chain.pem
c                     [         R                  " U S5        [        R                  " SSSS9R	                  U 5        [        R                  " SSSS	S	S
9R	                  U 5        g )Nz	to exportz--output-filezEThe path where the resulting PEM-encoded certificate will be written.T)helprequiredz--include-chainzWhether to include the certificate's issuer chain in the exported file. If this is set, the resulting file will contain the pem-encoded certificate and its issuing chain, ordered from leaf to root.
store_trueF)r   actiondefaultr   )r   AddCertPositionalResourceArgr   ArgumentAddToParser)parsers    ,lib/surface/privateca/certificates/export.pyArgsExport.ArgsV   s`    ..v{CMM	 #{6*MM  $F+    c                 X   [         R                  " SS9n[         R                  " SS9nUR                  R                  R                  5       nUR                  R                  UR                  UR                  5       S95      nUR                  /nUR                  (       a  XeR                  -  n[        R                  " UR                  [         R"                  " U5      5        [$        R&                  R)                  SR+                  UR                  5       UR                  5      5        g )Nv1)api_version)namez"Exported certificate [{}] to [{}].)privateca_baseGetClientInstanceGetMessagesModuleCONCEPTScertificateParse'projects_locations_caPools_certificatesGet7PrivatecaProjectsLocationsCaPoolsCertificatesGetRequestRelativeNamepemCertificateinclude_chainpemCertificateChainr
   WriteFileContentsoutput_filer   PemChainForOutputr	   statuswriteformat)selfargsclientmessagescertificate_refr%   	pem_chains          r   Run
Export.Runh   s    --$?F//DAHmm//557O@@DD	@	@ --/ 
A 
12K
 ++,I222i	D,,%77	BDJJ9@@$$&(8(8: ;r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r:   __static_attributes__r<   r   r   r   r   7   s     : , ,";r   r   N)rA   
__future__r   r   r    googlecloudsdk.api_lib.privatecar   r!   googlecloudsdk.calliope$googlecloudsdk.command_lib.privatecar   r   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   _DETAILED_HELPReleaseTracksReleaseTrackGASilentCommandr   r<   r   r   <module>rO      sq    2 &  ' C ( : > # * 	4 D%%(()A;T A; *A;r   