
    C                         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	 rS
 rS rS rS rS rS rS rS rg)z2Utility for updating Managed Microsoft AD domains.    )absolute_import)division)unicode_literals)
exceptions)util)labels_util)
console_ioc                 p   ^ / SQn[        U4S jU 5       5      (       a  U$ [        R                  " S5      e)z;Check that update command has one of these flags specified.)clear_labelsremove_labelsupdate_labels
add_regionremove_regionadd_authorized_networksremove_authorized_networksenable_audit_logsc              3   F   >#    U  H  nTR                  U5      v   M     g 7f)N)IsSpecified).0
update_argargss     Flib/googlecloudsdk/command_lib/active_directory/domains_update_util.py	<genexpr>'CheckFieldsSpecified.<locals>.<genexpr>'   s     D*		*	%	%s   !z6Must specify at least one field to update. Try --help.)anyr   ActiveDirectoryError)unused_domain_refr   patch_requestupdate_argss    `  r   CheckFieldsSpecifiedr       s;    	+ 	DDDD''>	@ @    c                     [         R                  " U 5      n[         R                  " U 5      nUR                  U R	                  5       S9nUR
                  R                  U5      $ )zFetch existing AD domain.)name)r   GetClientForResourceGetMessagesForResource9ManagedidentitiesProjectsLocationsGlobalDomainsGetRequestRelativeName!projects_locations_global_domainsGet)
domain_refclientmessagesget_reqs       r   GetExistingDomainr.   -   s[    $$Z0&((4(NN""$ O &'		1	1	5	5g	>>r!   c                 &    [        U 5      Ul        U$ )z?Fetch existing AD domain to update and add it to Patch request.)r.   domain)r*   unused_argsr   s      r   UpdatePatchRequestr2   6   s    *:6-	r!   c                     UR                   nU(       a$  UR                  U 5      S:X  a  US-   U -   Ul         U$ Xl         U$ )z"Adds name of field to update mask.r   ,)
updateMaskcount)fieldr   update_masks      r   AddFieldToUpdateMaskr9   <   sK    ((+1$!,s!2U!:m 
  %	r!   c                 p   [         R                  R                  U5      nUR                  5       (       a  [	        SU5      n[
        R                  " U 5      nUR                  UR                  R                  UR                  R                  5      R                  5       nU(       a  XRR                  l        U$ )zUpdates labels of domain.labels)r   DiffFromUpdateArgsMayHaveUpdatesr9   r   r%   ApplyDomainLabelsValuer0   r;   	GetOrNone)r*   r   r   labels_diffr,   
new_labelss         r   UpdateLabelsrE   G   s      //5+!!(=AM**:6H""8??#>#>#0#7#7#>#>@@I	 $.!	r!   c                    UR                   (       ap  UR                  (       d,  [        R                  " U 5      nUR	                  5       nXBl        UR                   UR                  l        [        SU5      n[        SU5      nU$ )zHReads the pfx file into the LDAPSSettings proto and updates the request.certificatePfxcertificatePassword)certificate_pfx_filelDAPSSettingsr   r%   LDAPSSettingsrG   r9   )r*   r   requestr,   settingss        r   ProcessPfxFilerN   T   sk    	  ,,Z8h'')h&+/+D+DG("#3W=G"#8'BG	.r!   c                  2    [         R                  " S5      n U $ )z&Prompt for user input of pfx password.z@Please enter the password used the encrypt the pfx certificate: )r	   PromptPassword)creds    r   GetPfxPassswordrR   a   s    		"	"H
J$	+r!   c                     A UR                   (       a  UR                   UR                  l        U$ UR                  (       a  U$ [	        5       nX2R                  l        U$ )zCAllows for the pfx password to be read from stdin if not specified.)certificate_passwordrJ   rH   clear_certificatesrR   )
unused_refr   rL   secrets       r   ReadPfxPasswordIfNeededrX   h   sN    	040I0IG-N	N&.4+	.r!   c                 Z    A UR                   (       a  [        SU5      n[        SU5      nU$ )NrG   rH   )rU   r9   )rV   r   rL   s      r   ClearCertificatesrZ   u   s-    	"#3W=G"#8'BG	.r!   N)__doc__
__future__r   r   r   'googlecloudsdk.api_lib.active_directoryr   +googlecloudsdk.command_lib.active_directoryr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.core.consoler	   r    r.   r2   r9   rE   rN   rR   rX   rZ    r!   r   <module>rb      sM    9 &  ' > < < 2@$?


r!   