
                             d Z ddlm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y)z:Client for interaction with Environment API CRUD DATAPLEX.    )absolute_import)division)unicode_literals)util)iam_utilc                    t        j                         j                  | j                         t        j                         j	                  |            }t        j
                         j                  j                  |      S )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                     t        j                         j                  | j                               }t        j                         j
                  j                  |      S )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                     t        |       }t        j                  t        j                         j
                  |||       t        | |      S )zAdd IAM policy binding request.)r   r   AddBindingToIamPolicyr   r   GoogleIamV1Bindingr   r   memberroler	   s       r   AddIamPolicyBindingr"   -   s@    (&
  ##%88&&$P	ov	..r   c                 ^    t        |       }t        j                  |||       t        | |      S )z"Remove IAM policy binding request.)r   r   RemoveBindingFromIamPolicyr   r   s       r   RemoveIamPolicyBindingr%   5   s+    (&
%%ffd;	ov	..r   c                 ~    t        j                  |t        j                         j                        }t        | |      S )z)Set IAM policy binding request from file.)r   ParsePolicyFiler   r   GoogleIamV1Policyr   )r   policy_filer	   s      r   SetIamPolicyFromFiler*   <   s6    ####%779& 
ov	..r   c                 2   t        j                         }|j                  | j                  | j                  | j
                        }|j                  | j                  | j                  | j                  | j                        }|j                  ||      }|S )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(8 R :	r   c                 |    t        j                         }|j                  | j                  | j                        }|S )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           	          t        j                         }|j                  | j                  | j                  t        j
                  |j                  |       t        |       t        |             }|S )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           	          t        j                         }|j                  | j                  | j                  t        j
                  |j                  |       t        |       t        |             S )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                 :   g }| j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d	      r|j                  d
       | j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d      r|j                  d       | j                  d      r|j                  d       |S )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   so   +	m$}%	n%}%	hx 	,->?	*+=>	./@A	()@A	/0AB	01BC	+,>?	1245	3467	r   c                 f    t        j                  | t        j                         j                        S )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   