
                             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 r
S rS	 rS
 rS rS rS rS rS rS rS rg)z:Client for interaction with Environment API CRUD DATAPLEX.    )absolute_import)division)unicode_literals)util)iam_utilc                     [         R                  " 5       R                  U R                  5       [         R                  " 5       R	                  US9S9n[         R
                  " 5       R                  R                  U5      $ )zSet Iam Policy request.)policy)resourcegoogleIamV1SetIamPolicyRequest)dataplex_apiGetMessageModule=DataplexProjectsLocationsLakesEnvironmentsSetIamPolicyRequestRelativeNameGoogleIamV1SetIamPolicyRequestGetClientInstance%projects_locations_lakes_environmentsSetIamPolicy)environment_refr	   set_iam_policy_reqs      2lib/googlecloudsdk/api_lib/dataplex/environment.pyr   r      sr    #44 AA++-%1%B%B%D%%V%4 B 6 
 
	'	' 
)),,7I*JK    c                     [         R                  " 5       R                  U R                  5       S9n[         R                  " 5       R
                  R                  U5      $ )zGet Iam Policy request.)r
   )r   r   =DataplexProjectsLocationsLakesEnvironmentsGetIamPolicyRequestr   r   r   GetIamPolicy)r   get_iam_policy_reqs     r   r   r   $   sX    #44 AA++- B /  
	'	' 
)),,7I*JKr   c                     [        U 5      n[        R                  " [        R                  " 5       R
                  X1U5        [        X5      $ )zAdd IAM policy binding request.)r   r   AddBindingToIamPolicyr   r   GoogleIamV1Bindingr   r   memberroler	   s       r   AddIamPolicyBindingr"   -   s<    (&
  ##%88&$P	o	..r   c                 \    [        U 5      n[        R                  " X1U5        [        X5      $ )z"Remove IAM policy binding request.)r   r   RemoveBindingFromIamPolicyr   r   s       r   RemoveIamPolicyBindingr%   5   s'    (&
%%fd;	o	..r   c                     [         R                  " U[        R                  " 5       R                  5      n[        X5      $ )z)Set IAM policy binding request from file.)r   ParsePolicyFiler   r   GoogleIamV1Policyr   )r   policy_filer	   s      r   SetIamPolicyFromFiler*   <   s4    ####%779& 
o	..r   c                     [         R                  " 5       nUR                  U R                  U R                  U R
                  S9nUR                  U R                  U R                  U R                  U R                  S9nUR                  X#S9nU$ )z+Generate InfrastructureSpec From Arguments.)
diskSizeGb	nodeCountmaxNodeCount)imageVersionjavaLibrariespythonPackages
properties)computeosImage)r   r   BGoogleCloudDataplexV1EnvironmentInfrastructureSpecComputeResourcescompute_disk_size_gbcompute_node_countcompute_max_node_count@GoogleCloudDataplexV1EnvironmentInfrastructureSpecOsImageRuntimeos_image_versionos_image_java_librariesos_image_python_packagesos_image_properties2GoogleCloudDataplexV1EnvironmentInfrastructureSpec)argsmodulecompute_resourceos_image_runtimeinfrastructure_specs        r   GenerateInfrastructureSpecrD   D   s    ((*&^^**''.. _ 0 \\((0022))	 ] +
 QQ R :	r   c                 x    [         R                  " 5       nUR                  U R                  U R                  S9nU$ )z$Generate SessionSpec From Arguments.)enableFastStartupmaxIdleDuration)r   r   +GoogleCloudDataplexV1EnvironmentSessionSpecsession_enable_fast_startupsession_max_idle_duration)r?   r@   session_specs      r   GenerateSessionSpecrL   U   s@    ((*&CC8844 D 6, 
r   c           	          [         R                  " 5       nUR                  U R                  U R                  [         R
                  " UR                  U 5      [        U 5      [        U 5      S9nU$ )z/Create Environment for Message Create Requests.descriptiondisplayNamelabelsinfrastructureSpecsessionSpecr   r    GoogleCloudDataplexV1EnvironmentrO   display_nameCreateLabelsrD   rL   )r?   r@   requests      r   #GenerateEnvironmentForCreateRequestrY   ^   sg    ((*&33""##&&v'N'N'+-3D9%d+ 4 -' 
.r   c           	          [         R                  " 5       nUR                  U R                  U R                  [         R
                  " UR                  U 5      [        U 5      [        U 5      S9$ )z/Create Environment for Message Update Requests.rN   rT   )r?   r@   s     r   #GenerateEnvironmentForUpdateRequestr[   k   sc    ((*&		0	0""##&&v'N'N'+-3D9%d+ 
1 
- -r   c                    / n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  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  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  UR                  S5        U R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        U$ )z$Create Update Mask for Environments.rO   rV   rP   rQ   r6   z%infrastructureSpec.compute.diskSizeGbr7   z$infrastructureSpec.compute.nodeCountr8   z'infrastructureSpec.compute.maxNodeCountr:   z'infrastructureSpec.osImage.imageVersionr;   z(infrastructureSpec.osImage.javaLibrariesr<   z)infrastructureSpec.osImage.pythonPackagesr=   z%infrastructureSpec.osImage.propertiesrJ   zsessionSpec.maxIdleDurationrI   zsessionSpec.enableFastStartup)IsSpecifiedappend)r?   update_masks     r   GenerateUpdateMaskr`   w   s   +	m$$}%	n%%}%	hx 	,-->?	*++=>	.//@A	())@A	/00AB	011BC	+,,>?	12245	34467	r   c                 j    [         R                  " U [         R                  " 5       R                  5      $ )z=Waits for the given google.longrunning.Operation to complete.)r   WaitForOperationr   r   )	operations    r   rb   rb      s,    		&	&$$&LL
N Nr   N)__doc__
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   googlecloudsdk.command_lib.iamr   r   r   r"   r%   r*   rD   rL   rY   r[   r`   rb    r   r   <module>ri      sT    A &  ' @ 3KK///"
	-<Nr   