
                             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)z6Client for interaction with CONTENT API CRUD DATAPLEX.    )absolute_import)division)unicode_literals)util)iam_utilc                    t        j                         j                  | j                         t        j                         j	                  |            }t        j
                         j                  j                  |      S )zSets Iam Policy request.)policy)resourcegoogleIamV1SetIamPolicyRequest)dataplex_apiGetMessageModule8DataplexProjectsLocationsLakesContentSetIamPolicyRequestRelativeNameGoogleIamV1SetIamPolicyRequestGetClientInstance projects_locations_lakes_contentSetIamPolicy)content_refr	   set_iam_policy_reqs      .lib/googlecloudsdk/api_lib/dataplex/content.pyr   r      sq    #44 <<'')%1%B%B%D%%V%4 = 6 
 
	'	' 
$$\\2D%EF    c                     t        j                         j                  | j                               }t        j                         j
                  j                  |      S )zGets Iam Policy request.)r
   )r   r   8DataplexProjectsLocationsLakesContentGetIamPolicyRequestr   r   r   GetIamPolicy)r   get_iam_policy_reqs     r   r   r   $   sW    #44 <<'') = +  
	'	' 
$$\\2D%EFr   c                     t        |       }t        j                  t        j                         j
                  |||       t        | |      S )z Adds iam policy binding request.)r   r   AddBindingToIamPolicyr   r   GoogleIamV1Bindingr   )r   memberroler	   s       r   AddIamPolicyBindingr!   -   s@    $&
  ##%88&&$P	k6	**r   c                 ^    t        |       }t        j                  |||       t        | |      S )z#Removes iam policy binding request.)r   r   RemoveBindingFromIamPolicyr   )lake_refr   r    r	   s       r   RemoveIamPolicyBindingr%   5   s+    !&
%%ffd;	h	''r   c                 ~    t        j                  |t        j                         j                        }t        | |      S )z*Sets iam policy binding request from file.)r   ParsePolicyFiler   r   GoogleIamV1Policyr   )r   policy_filer	   s      r   SetIamPolicyFromFiler*   <   s6    ####%779& 
k6	**r   c                 @   t        j                         }|j                  | j                  | j                  t        j
                  |j                  |       | j                        }| j                  rt        |       |_	        | j                  rt        |       |_        |S )z,Creates Content for Message Create Requests.dataTextdescriptionlabelspathr   r   GoogleCloudDataplexV1Content	data_textr.   CreateLabelsr0   kernel_typeGenerateNotebooknotebookquery_engineGenerateSqlScript	sqlScriptargsmodulecontents      r   GenerateContentForCreateRequestr?   D       ((*&//~~""&&v'J'J'+-99 0 ' 
'-G	)$/G	.r   c                 @   t        j                         }|j                  | j                  | j                  t        j
                  |j                  |       | j                        }| j                  rt        |       |_	        | j                  rt        |       |_        |S )z,Creates Content for Message Update Requests.r,   r1   r;   s      r   GenerateContentForUpdateRequestrB   T   r@   r   c                     t        j                         }|j                  }|j                         }| j                  r |j	                  | j                        |_        |S )zBCreates Notebook field for Content Message Create/Update Requests.)r   r   $GoogleCloudDataplexV1ContentNotebookr5   KernelTypeValueValuesEnum
kernelType)r<   r=   kernel_type_fieldr7   s       r   r6   r6   d   sT    ((*&AA88:(	+EEH	/r   c                     t        j                         }|j                  }|j                         }| j                  r |j	                  | j                        |_        |S )zDCreates SQL Script field for Content Message Create/Update Requests.)r   r   %GoogleCloudDataplexV1ContentSqlScriptr8   EngineValueValuesEnumengine)r<   r=   query_engine_field
sql_scripts       r   r9   r9   o   sU    ((*&CC;;=*	*@@J	r   c                     ddddddd}g }|j                         D ](  \  }}| j                  |      s|j                  |       * |S )z Creates Update Mask for Content.r.   r/   r0   zsqlScript.engineznotebook.kernelTyper3   )r.   r/   r0   r8   r5   r3   )itemsIsSpecifiedappend)r<   args_api_field_mapupdate_maskkvs        r   GenerateUpdateMaskrV   z   s`     #(* + &&(da ) 
r   c                 f    t        j                  | t        j                         j                        S )z=Waits for the given google.longrunning.Operation to complete.)r   WaitForOperationr   r   )	operations    r   rX   rX      s,    		&	&$$&GG
I Ir   N)__doc__
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   googlecloudsdk.command_lib.iamr   r   r   r!   r%   r*   r?   rB   r6   r9   rV   rX    r   r   <module>r_      sS    = &  ' @ 3FF+(+  $Ir   