
                         l    S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r
  SSKrS rS	 rS
 rS rg)z6Utilities for "gcloud metastore federations" commands.    )absolute_import)division)unicode_literalsN)
exceptions)
validatorsc                 .    [         R                  " X5      $ )a7  Construct the backend names for create requests of Dataproc Metastore federations.

Args:
  job_ref: A resource ref to the parsed Federation resource.
  args: The parsed args namespace from CLI.
  create_federation_req: Create federation request for the API call.

Returns:
  Modified request for the API call.
)	validatorParseBackendsIntoRequest)job_refargscreate_federation_reqs      <lib/googlecloudsdk/command_lib/metastore/federations/util.pyGenerateCreateBackendsr      s     
	+	+G	KK    c                     [        UR                  5       5      nSU;   a  SU;  a  0 UR                  l        SU;   a  [        R
                  " X5        [        U5      Ul        U$ )aO  Construct the long name for backends and updateMask for update requests of Dataproc Metastore federations.

Args:
  job_ref: A resource ref to the parsed Federation resource.
  args: The parsed args namespace from CLI.
  update_federation_req: Update federation request for the API call.

Returns:
  Modified request for the API call.
--remove-backends--update-backends)setGetSpecifiedArgNames
federationbackendMetastoresr	   r
   _GenerateUpdateMask
updateMask)r   r   update_federation_reqargs_sets       r   GenerateUpdateBackendsr   ,   s`     **,-(H$)<H)L9;$$6H$&&wF%8%>"	r   c                     U S-   U-   $ )N. )prefixkeys     r   _AppendKeysToUpdateMaskr"   A   s    	#	r   c           
      "   SSS.n[        5       n[        U R                  5       5      nUR                  U5       H  nUR                  X   5        M     U GH  nSU;  a  SU:X  aS  U R                  nUR                  S5      nU H0  nUR                  [        SUR                  S5      S   5      5        M2     SU:X  aA  U R                  n	U	R                  S5      n
U
 H  nUR                  [        SU5      5        M      SU;  d  M  S	U:X  a.  U R                   H  nUR                  [        SU5      5        M      S
U:X  d  M  U R                   H  nUR                  [        SU5      5        M      GM     SR                  [        U5      5      $ )zConstructs updateMask for federation patch requests.

Args:
  args: The parsed args namespace from CLI.

Returns:
  String containing update mask for patch request.
backend_metastoreslabels)z--clear-backendsz--clear-labelsr   ,=r   r   z--update-labelsz--remove-labels)r   r   intersectionaddupdate_backendssplitr"   remove_backendsupdate_labelsremove_labelsjoinsorted)r   arg_name_to_fieldupdate_mask
input_argsarg_nameargupdate_backends_valuebackends_listbackendremove_backends_valuebackend_keys_listr!   s               r   r   r   E   s    / 
 +4,,./*))*;<hOO%/0 = c;.		# $ 4 4-33C8$G
//%&:&-mmC&8&;=> % 
	# $ 4 4177<(G
//%&:GDF ) {"	c	!%%C
//1(C@
A &	c	!%%C
//1(C@
A &+ 0 
&%	&&r   )__doc__
__future__r   r   r   regooglecloudsdk.callioper   $googlecloudsdk.command_lib.metastorer   r	   sixr   r   r"   r   r   r   r   <module>rA      s4    = &  ' 	 . H 
L*,'r   