
    S                         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 rS rS rg)z"Helpers for update commands in GA.    )absolute_import)division)unicode_literals)base)
exceptions)flags)	pem_utils)labels_util)filesc                      [         R                  " U 5      n[        R                  " U5      $ ! [         R                  [
        [        4 a'    [        R                  " SSR                  U 5      5      ef = f)zParses a pem chain from a file.

Args:
  pem_chain_file: file containing the pem_chain.

Returns:
  The string list of certs in the chain.
z	pem-chainz,Could not read provided PEM chain file '{}'.)
r   ReadFileContentsr	   ValidateAndParsePemChainErrorOSErrorIOErrorr   InvalidArgumentExceptionformat)pem_chain_filepem_chain_inputs     8lib/googlecloudsdk/command_lib/privateca/update_utils.py_ParsePemChainFromFiler      sf    ,,^<O--o>>
++w	( 

-
-6==nM s
   +. AA4c                 4   [         R                  " SS9nUR                  5       n/ nU R                  S5      (       aE  UR	                  UR                  [        U R                  5      S9S9Ul        UR                  S5        [        R                  R                  U 5      nUR                  UR                  R                  U5      nUR                  (       a"  UR                   Ul        UR                  S5        U(       d  ["        R$                  " S5      eX44$ )	ao  Creates a CA object and update mask from CA update flags.

Requires that args has 'pem-chain' and update labels flags registered.

Args:
  args: The parser that contains the flag values.
  current_labels: The current set of labels for the CA.

Returns:
  A tuple with the CA object to update with and the list of strings
  representing the update mask, respectively.
v1)api_version	pem_chain)pemCertificates)pemIssuerChainsubordinate_configlabelsz&No updates found for the requested CA.)privateca_baseGetMessagesModuleCertificateAuthorityIsKnownAndSpecifiedSubordinateConfigSubordinateConfigChainr   r   subordinateConfigappendr
   DiffFromUpdateArgsApplyLabelsValueneeds_updater   privateca_exceptionsNoUpdateExceptions)argscurrent_labelsmessagesca_to_updateupdate_masklabels_difflabels_updates          r   UpdateCAFromArgsr6   2   s    --$?(..0,+	k**%-%?%?6624>>B 7 
 &@ &L"
 +,  //5+####//- '..Lx 	

1
10  
	""    c                    [         R                  " S5      nUR                  5       n/ nU R                  S5      (       d,  U R                  S5      (       d  U R                  S5      (       a  UR	                  5       Ul        U R                  S5      (       a,  U R                  UR
                  l        UR                  S5        U R                  S5      (       a,  U R                  UR
                  l
        UR                  S5        U R                  S5      (       a6  [        R                  " U 5      UR
                  l        UR                  S5        U R                  S5      (       a/  UR                  U R                  S	9Ul        UR                  S
5        ["        R$                  R'                  U 5      nUR)                  UR                  R*                  U5      nUR,                  (       a"  UR.                  Ul        UR                  S5        U R                  S5      (       a,  [        R0                  " U 5      Ul        UR                  S5        U(       d  [4        R6                  " S5      eX44$ )a  Creates a CA pool object and update mask from CA pool update flags.

Requires that args has 'publish-crl', 'publish-ca-cert', 'encryption-key' and
update labels flags registered.

Args:
  args: The parser that contains the flag values.
  current_labels: The current set of labels for the CA pool.

Returns:
  A tuple with the CA pool object to update with and the list of strings
  representing the update mask, respectively.
r   publish_crlpublish_ca_certpublishing_encoding_formatzpublishing_options.publish_crlz"publishing_options.publish_ca_certz"publishing_options.encoding_formatencryption_key)cloudKmsKeyencryption_specr   issuance_policyz+No updates found for the requested CA pool.)r    r!   CaPoolIsSpecifiedPublishingOptionspublishingOptionsr9   
publishCrlr'   r:   publishCaCertr   ParseEncodingFormatFlagencodingFormatEncryptionSpecr<   encryptionSpecr
   r(   r)   r*   r+   r,   r   ParseIssuancePolicyissuancePolicyr-   r.   )r/   r0   r1   pool_to_updater3   r4   r5   s          r   UpdateCaPoolFromArgsrM   Z   s    --d3(??$.+ }%%			+	,	,			6	7	7'/'A'A'CN$&&484D4Dn&&19:)**7;7K7Kn&&4=>455

'
'
- &&5 =>	&''$,$;$;'' %< %N! ()  //5+##HOO$?$?P-)00Nx 	'(($)$=$=d$CN!()	

1
15  
	$$r7   N)__doc__
__future__r   r   r    googlecloudsdk.api_lib.privatecar   r    googlecloudsdk.callioper   $googlecloudsdk.command_lib.privatecar-   r   r	   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.core.utilr   r   r6   rM    r7   r   <module>rV      s8    ) &  ' C . S 6 : < *(%#P9%r7   