
    )                        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KJr  SSKJr  \R(                  " \R*                  R,                  5       " S S\R.                  5      5       rg)z"Update a new certificate template.    )absolute_import)division)unicode_literals)base)request_utils)
exceptions)flags)
operations)resource_args)labels_util)logc                   >    \ rS rSrSrSSS.rS r\S 5       rS r	Sr
g	)
Create    zUpdate a certificate template.a          To update a template named "dns-restricted" with new default x509 extensions:

          $ {command} dns-restricted --location=us-west1 --predefined-values-file=x509_parameters.yaml

        To update a template named "dns-restricted" to allow requestors to specify subject:

          $ {command} dns-restricted --location=us-west1 --copy-subject

        To update a template named "dns-restricted" with allowed extension
        'base-key-usage' to allow requestors to specify additional x509 extension 'extended-key-usage':

          $ {command} dns-restricted --location=us-west1 --copy-known-extensions=base-key-usage,extended-key-usage

        To update a template named "mtls-restricted" with allowed OID
        '1.1' to allow requestors to specify alternative OIDS '2.2,3.3':

          $ {command} mtls-restricted --location=us-west1 --copy-extensions-by-oid=2.2,3.3
       )DESCRIPTIONEXAMPLESc                 p   [         R                  " S5      nUR                  5       n/ nUR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  [        R
                  " U5      Ul        UR                  S5      (       a  UR                  S5        UR                  S5      (       a  UR                  S5        UR                  S5      (       a  UR                  S5        UR                  S5      (       a,  [        R                  " U5      Ul	        UR                  S	5        UR                  S
5      (       a"  UR                  Ul
        UR                  S
5        UR                  S5      =(       d    UR                  S5      nUR                  S5      =(       d    UR                  S5      nU(       d  U(       aK  [        R                  " U5      Ul        U(       a  UR                  S5        U(       a  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XE4$ )a&  Creates a Certificate template object and update mask from Certificate template update flags.

Requires that args has 'description', 'copy-sans', 'copy-subject',
'predefined-values-file', 'copy-known-extensions', 'copy-extensions-by-oid',
and update labels flags registered.

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

Returns:
  A tuple with the Certificate template object to update with and the list
  of
  strings representing the update mask, respectively.
v1	copy_sanscopy_subjectidentity_cel_expressionz8identity_constraints.allow_subject_alt_names_passthroughz.identity_constraints.allow_subject_passthroughz#identity_constraints.cel_expressionpredefined_values_filepredefined_valuesdescriptioncopy_known_extensionsdrop_known_extensionscopy_extensions_by_oiddrop_oid_extensionsz'passthrough_extensions.known_extensionsz,passthrough_extensions.additional_extensionslabelsz8No updates found for the requested certificate template.)privateca_baseGetMessagesModuleCertificateTemplateIsSpecifiedr	   ParseIdentityConstraintsidentityConstraintsappendParsePredefinedValuespredefinedValuesr   ParseExtensionConstraintspassthroughExtensionsr   DiffFromUpdateArgsApplyCaPoolLabelsValueneeds_updater   privateca_exceptionsNoUpdateException)
selfargscurrent_labelsmessagestemplate_to_updateupdate_maskknown_exts_flagsoid_exts_flagslabels_difflabels_updates
             )lib/surface/privateca/templates/update.py"_UpdateCertificateTemplateFromArgs)Create._UpdateCertificateTemplateFromArgs;   s[     //5H!557K 	%%N++566/4/M/M
0, 
		+	&	&F	
 
		.	)	)KL			3	4	4@A011,1,G,G,M),-&&'+'7'7$''' 3			1	2  %%  1			/	0  > 
)
)$
/ . 
DE	IJ""11$7K%%##^M !!"/"6"6" 22
D  **    c                 (   [         R                  " U S5        [        R                  " SSS9R	                  U 5        [
        R                  " U 5        [
        R                  " U SS9  [
        R                  " U 5        [        R                  " U 5        g )Nz	to updatez--descriptionz0A text description for the Certificate Template.)helpF)require_passthrough_flags)r   +AddCertificateTemplatePositionalResourceArgr   ArgumentAddToParserr	   AddPredefinedValuesFileFlagAddIdentityConstraintsFlags%AddExtensionConstraintsFlagsForUpdater   AddUpdateLabelsFlags)parsers    r=   ArgsCreate.Args   sm    == 	MMPk&	%%f-	%%fN	//7$$V,r@   c           	      B   [         R                  " S5      n[         R                  " S5      nUR                  R                  R                  5       nUR                  5       nUR                  R                  UR                  US95      nU R                  XR                  5      u  px[        R                  " UUR                  R                  UR                  R                   SS9  UR                  R#                  UR%                  UUSR'                  U5      [(        R*                  " 5       S95      n	[,        R.                  " U	SSS9n
[,        R0                  " XR2                  5      n[4        R6                  R9                  S	R;                  UR<                  5      5        g )
Nr   )nameT)existing_copy_subjexisting_copy_sans
for_update,)rO   certificateTemplate
updateMask	requestIdzUpdating Certificate Template.)api_versionz"Updated Certificate Template [{}].)r    GetClientInstancer!   CONCEPTScertificate_templateParseRelativeName'projects_locations_certificateTemplatesGet8PrivatecaProjectsLocationsCertificateTemplatesGetRequestr>   r   r	   ValidateIdentityConstraintsr%   allowSubjectPassthroughallowSubjectAltNamesPassthroughPatch:PrivatecaProjectsLocationsCertificateTemplatesPatchRequestjoinr   GenerateRequestIdr
   AwaitGetMessageFromResponser"   r   statusPrintformatrO   )r3   r4   clientr6   cert_template_reftemplate_namecurrent_cert_templatecert_template_to_updater8   	operationcert_template_responsecert_templates               r=   Run
Create.Run   st   --d3F//5H::@@B%224M"JJNNII 	J 	
 	//..	
 ) 
%%0DD\\0DDdd	 >>DDKK 7xx,#557	 	L 	
I (--3 55 < <M JJ,33M4F4FGr@    N)__name__
__module____qualname____firstlineno____doc__detailed_helpr>   staticmethodrL   rt   __static_attributes__rv   r@   r=   r   r       s6    ' :-.N+` 
- 
-.r@   r   N)r{   
__future__r   r   r    googlecloudsdk.api_lib.privatecar   r    r   googlecloudsdk.calliope$googlecloudsdk.command_lib.privatecar   r1   r	   r
   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   ReleaseTracksReleaseTrackGACreateCommandr   rv   r@   r=   <module>r      si    ) &  ' C : ( S 6 ; > < # D%%(()eT e *er@   