
    #                         d Z ddlmZ ddlmZ ddlmZ ddlmZ d Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)zUtility for updating Looker instances.

This utily is primarily used for modifying request hooks for update requests for
Looker instances. See go/gcloud-creating-commands#request-hooks for more
details.
    )absolute_import)division)unicode_literals)
console_ioc                  B    d} | dz  } t        j                  | dd       y)z:Adds prompt that warns about allowed email domains update.z3Change to instance allowed email domain requested. zUpdating the allowed email domains from cli means the value provided will be considered as the entire list and not an amendment to the existing list of allowed email domains.#Do you want to proceed with update?Tmessageprompt_stringcancel_on_noNr   PromptContinuer
   s    >lib/googlecloudsdk/command_lib/looker/instances_update_util.py_WarnForAdminSettingsUpdater      s/    A'	1'
 9    c                  B    d} | dz  } t        j                  | dd       y)z1Adds prompt that warns about allowed vpcs update.zIChange to instance PSC allowed Virtual Private Cloud networks requested. zUpdating the allowed VPC networks from cli means the value provided will be considered as the entire list and not an amendment to the existing list of allowed vpcs.r   Tr	   Nr   r   s    r   _WarnForPscAllowedVpcsUpdater   ,   s6     
 
('
 9r   c                  8    d} t        j                  | dd       y)z2Adds prompt that warns about allowed vpcs removal.z0Removal of instance PSC allowed vpcs requested. z8Do you want to proceed with removal of PSC allowed vpcs?Tr	   Nr   r   s    r   #_WarnForPscAllowedVpcsRemovalUpdater   >   s    >'Nr   c                  B    d} | dz  } t        j                  | dd       y)z8Adds prompt that warns about service attachments update.z6Change to instance PSC service attachments requested. zUpdating the PSC service attachments from cli means the value provided will be considered as the entire list and not an amendment to the existing list of PSC service attachmentsr   Tr	   Nr   r   s    r   #_WarnForPscServiceAttachmentsUpdater   I   s/    D'	2'
 9r   c                  8    d} t        j                  | dd       y)z9Adds prompt that warns about service attachments removal.z7Removal of instance PSC service attachments requested. z;Do you want to proceed with removal of service attachments?Tr	   Nr   r   s    r   *_WarnForPscServiceAttachmentsRemovalUpdater   X   s    E'
Gr   c                 t    |j                   }|r"|j                  |       dk(  r|d| |_         |S | |_         |S )am  Adds fields to the update mask of the patch request.

  Args:
    field: the field of the update mask to patch request for Looker instances.
    patch_request: the request of the actual update command to be modified

  Returns:
    A patch request object to be sent to the server. The object is an instance
    of UpdateInstanceRequest: http://shortn/_yn9MhWaGJx
  r   ,)
updateMaskcount)fieldpatch_requestupdate_masks      r   AddFieldToUpdateMaskr"   e   sJ     ((+1$,7!?m 
  %M	r   c                     |j                  d      r;t                |j                  |j                  j                  _        t        d|      }|S )zNPython hook to modify allowed email domains in looker instance update request.allowed_email_domainsz$admin_settings.allowed_email_domains)IsSpecifiedr   r$   instanceadminSettingsallowedEmailDomainsr"   unused_instance_refargsr    s      r   ModifyAllowedEmailDomainsr,   y   sO    	-.  !"" ((< ).M 
r   c                 b    |j                  d      s|j                  d      rt        d|      }|S )zDHook to update maintenance window to the update mask of the request.maintenance_window_daymaintenance_window_timemaintenance_windowr%   r"   r)   s      r   UpdateMaintenanceWindowr2      s6    	./43C3C4 ))=}MM	r   c                 @    |j                  d      rt        d|      }|S )zEHook to update public IP to the update mask of the request for alpha.enable_public_ipr1   r)   s      r   UpdateEnablePublicIpAlphar5      s$    	()();]KM	r   c                 @    |j                  d      rt        d|      }|S )zAHook to update public IP to the update mask of the request fo GA.public_ip_enabledr1   r)   s      r   UpdatePublicIPEnabledr8      s$    	)*()<mLM	r   c                 z    |j                  d      r)|j                  d      rt        d|      }t        d|      }|S )z?Hook to update Oauth configs to the update mask of the request.oauth_client_idoauth_client_secretzoauth_config.client_idzoauth_config.client_secretr1   r)   s      r   UpdateOauthClientr<      sK    	'(T-=-=. ) -M )$mM 
r   c                     |j                  d      s"|j                  d      s|j                  d      rt        d|      }|S )zIHook to update deny maintenance period to the update mask of the request."deny_maintenance_period_start_date deny_maintenance_period_end_datedeny_maintenance_period_timedeny_maintenance_periodr1   r)   s      r   UpdateDenyMaintenancePeriodrB      sH     ;<			<	=			8	9(!=M 
r   c                     |j                  d      s"|j                  d      s|j                  d      rt        d|      }|S )zDHook to update deny user metadata to the update mask of the request.add_viewer_usersadd_standard_usersadd_developer_usersuser_metadatar1   r)   s      r   UpdateUserMetadatarH      sC     )*			.	/			/	0(-HM	r   c                 @    |j                  d      rt        d|      }|S )z?Hook to update custom domain to the update mask of the request.custom_domainr1   r)   s      r   UpdateCustomDomainrK      s"    	o&(-HM	r   c                     |j                  d      r=t                |j                  |j                  j                  _        t        d|      }|S |j                  d      rt                t        d|      }|S )zJHook to update psc confing allowed vpcs to the update mask of the request.psc_allowed_vpcszpsc_config.allowed_vpcsclear_psc_allowed_vpcs)r%   r   rM   r&   	pscConfigallowedVpcsr"   r   r)   s      r   UpdatePscAllowedVpcsrQ      sx    	() !"373H3HM$$0(!=M 
 01')(!=M 
r   c                     |j                  d      rt                t        d|      }|S |j                  d      rt                t        d|      }|S )zQHook to update psc confing service attachments to the update mask of the request.psc_service_attachmentzpsc_config.service_attachmentsclear_psc_service_attachments)r%   r   r"   r   r)   s      r   UpdatePscServiceAttachmentsrU      s\    	./')((-M 
 78.0((-M 
r   c                     |j                  d      rt        d|      }|j                  d      rt        d|      }|j                  d      rt        d|      }|S )z@Hook to update gemini enabled to the update mask of the request.gemini_enabledgemini_preview_tester_enabledzgemini_ai_config.trusted_testergemini_prompt_log_enabledzgemini_ai_config.prompt_loggingr1   r)   s      r   UpdateGeminiAiConfigrZ      sd    	&'()9=IM	56()=M 
12()=M 
r   N)__doc__
__future__r   r   r   googlecloudsdk.core.consoler   r   r   r   r   r   r"   r,   r2   r5   r8   r<   rB   rH   rK   rQ   rU   rZ    r   r   <module>r_      sm    '  ' 2$
(
$r   