
    h                        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dlm	Z	 ddl
mZ  e	j                  e	j                  j                  e	j                  j                         G d	 d
e	j                                Zd ZddZy)zThe `groups preview` command.    )absolute_import)division)unicode_literals)admin_directory)arg_parsers)base)	arg_utilsc                   0    e Zd ZdZdddZed        Zd Zy)PreviewzBRetrieve a list of users in a customer account using CEL query.
  z{description}a            To retrieve a list of user in a customer and filter it with a query, run:

            $ {command} --query="user.locations.exists(loc, loc.desk_code == 'abc')" --customer=A1234abcd

          To retrieve a list of users with only fullName and primaryEMail fields, run:

            $ {command} --query="user.locations.exists(loc, loc.desk_code == 'abc')" --customer=A1234abcd --format="flattened(nextPageToken, users[].primaryEmail, users[].name.fullName)"

          )DESCRIPTIONEXAMPLESc                 v   | j                  d      }|j                  dd       | j                  dd       | j                  dg d	d
d       | j                  ddt        j                         d       | j                  dddgdd       | j                  ddt        d       | j                  dd       y )NT)requiredz
--customerz3The customer ID for the customer's G Suite account.)helpz--queryz4Query string using CEL and supported user attributesz--projection)basicfullcustomr   z)Subsets of fields to fetch for this user.)choicesdefaultr   z--custom-field-maskzcustom-maskzA comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when --projection=custom.)metavartyper   z--view-typez
admin-viewzdomain-publiczOWhether to fetch the administrator-only or domain-wide public view of the user.z--max-resultsd   zOMaximum number of results to return. Acceptable values are 1 to 500, inclusive.)r   r   r   z--page-tokenz'Token to specify next page in the list.)add_mutually_exclusive_groupadd_argumentr   ArgListint)parser
scope_argss     &lib/surface/identity/groups/preview.pyArgszPreview.Args0   s    44d4CJD  G D  G +8	  :
   "%	  ' /"	  $  	  " G  J    c                    t        j                         }t        |j                  |j                  j
                        }t        |j                  |j                  j                        }t        j                  |j	                  |j                  |j                  ||j                  ||j                  |j                              S )N)customerquery
projectioncustomFieldMaskviewType
maxResults	pageToken)r   GetMessagesChoiceToEnumr%   DirectoryUsersListRequestProjectionValueValuesEnum	view_typeViewTypeValueValuesEnumr   r#   r$   custom_field_maskmax_results
page_token)selfargsmessagesr%   r.   s        r   RunzPreview.RunV   s    **,H		+	+	E	EHJ 		+	+	C	CFI ""**]]**! 22''oo 	+ 	'( (r!   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr    r6    r!   r   r   r      s4    
 		-  #J #JJ(r!   r   c                 &    | j                  dd      S )zDConverts an argument value to the string representation of the Enum.-_)replace)choices    r   ChoiceToEnumNamerC   j   s    	S	!!r!   Nc                    | yt        |       }|xs1 |j                         D cg c]  }t        j                  |       c}}	 |j	                  |      S c c}w # t
        $ rZ t        j                  dj                  |t        j                  |      dj                  d t        |      D                          w xY w)z6Converts the typed choice into an apitools Enum value.Nz;Invalid {item}: {selection}. Valid choices are: [{values}].z, c              3       K   | ]  }|  y w)Nr=   ).0cs     r   	<genexpr>zChoiceToEnum.<locals>.<genexpr>~   s     >(=1Q(=s   )item	selectionvalues)rC   namesr	   EnumNameToChoicelookup_by_nameKeyErrorr   ArgumentTypeErrorformatjoinsorted)rB   	enum_type	item_typevalid_choicesnamens         r   r+   r+   o   s    ^	&	!$ A.7oo.?@.?y!!!$.?@ A##D)) A 
 A

'
'ELL00699>}(=>> 	M 	@A AAs   AA A#B>)rB   N)r:   
__future__r   r   r   googlecloudsdk.api_lib.identityr   googlecloudsdk.callioper   r   $googlecloudsdk.command_lib.util.apisr	   ReleaseTracksReleaseTrackALPHABETACommandr   rC   r+   r=   r!   r   <module>rb      su    $ &  ' ; / ( : D%%++T->->-C-CDK(dll K( EK(\"
Ar!   