
    
                         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  \R                  " \R                  R                  5       " S S	\R                   5      5       rg
)z6Get the root CA certs for all active CAs in a CA Pool.    )base)request_utils)	pem_utils)resource_args)log)filesc                   4    \ rS rSrSr\S 5       rS rS rSr	g)
GetCaCerts   zGet the root CA certs for all active CAs in the CA pool.

## EXAMPLES

  To get the root CA certs for all active CAs in the CA pool:

    $ {command} my-pool --output-file=ca-certificates.pem \
        --location=us-west1
c                 |    [         R                  " U S5        [        R                  " SSSS9R	                  U 5        g )Nz'whose CA certificates should be fetchedz--output-filezThe path where the concatenated PEM certificates will be written. This will include the root CA certificate for each active CA in the CA pool. T)helprequired)r   AddCaPoolPositionalResourceArgr   ArgumentAddToParser)parsers    +lib/surface/privateca/pools/get_ca_certs.pyArgsGetCaCerts.Args'   s;    009;MM* 
 #{6*    c           	         [         R                  " S5      n[         R                  " S5      nUR                  R	                  UR                  UR                  5       UR                  [        R                  " 5       S9S95      nUR                   Vs/ s H  oUR                  S   PM     nnSR                  [        R                  " U5      5      $ s  snf )z<Returns the root CA certs for all active CAs in the CA pool.v1)	requestId)caPoolfetchCaCertsRequest )privateca_baseGetClientInstanceGetMessagesModuleprojects_locations_caPoolsFetchCaCerts4PrivatecaProjectsLocationsCaPoolsFetchCaCertsRequestRelativeNameFetchCaCertsRequestr   GenerateRequestIdcaCertscertificatesjoinr   PemChainForOutput)selfca_pool_refclientmessagesfetch_ca_certs_responsechain
root_certss          r   _GetRootCertsGetCaCerts._GetRootCerts2   s    --d3F//5H$??LLEE++- ( < <'99; != != 	F 	>? -D,K,K,K52,K   779..z:;;s   Cc                     UR                   R                  R                  5       nU R                  U5      n[        R
                  " UR                  U5        [        R                  R                  SR                  UR                  5      5        g )Nz%Exported the CA certificates to [{}].)CONCEPTSca_poolParser2   r   WriteFileContentsoutput_filer   statuswriteformat)r+   argsr,   pem_bags       r   RunGetCaCerts.RunA   si    --''--/K  -G	D,,g6JJ<CC r    N)
__name__
__module____qualname____firstlineno____doc__staticmethodr   r2   r?   __static_attributes__rA   r   r   r
   r
      s%     + +<r   r
   N)rF    googlecloudsdk.api_lib.privatecar   r   r   googlecloudsdk.calliope$googlecloudsdk.command_lib.privatecar   r   googlecloudsdk.corer   googlecloudsdk.core.utilr   ReleaseTracksReleaseTrackGACommandr
   rA   r   r   <module>rR      sX    = D : ( : > # * D%%(()* * **r   