
                         N   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SKJ	r	  SSK
Jr  SS	K
Jr  S
 rS rS r\R                   " SSS9r\R                   " SS\SS9r\R                   " SSSSS9r\R                   " SS\SS9r " S S\	R*                  5      r " S S\5      rg) zCUtilities related to adding flags for the gcloud meta api commands.    )absolute_import)division)unicode_literals)base)
exceptions)parser_extensions)arg_marshalling)registryc                  j    [         R                  " 5        Vs/ s H  oR                  PM     sn$ s  snf N)r
   
GetAllAPIsname)_as     1lib/googlecloudsdk/command_lib/meta/apis/flags.pyAPICompleterr      s'    "--/	0/Q&&/	00	0   0c                  j    [         R                  " 5        Vs/ s H  oR                  PM     sn$ s  snf r   )r
   GetAPICollections	full_name)r   cs     r   CollectionCompleterr   !   s'    '99;	<;!++;	<<	<r   c                     A [        USS 5      nU(       d  / $ [        R                  " U5       Vs/ s H  oDR                  PM     sn$ s  snf )N
collection)getattrr
   
GetMethodsr   )prefixparsed_argsr   r   ms        r   MethodCompleterr    %   sB    {L$7*	I"--j9	:9Q&&9	::	:s   Az--api-versionzbThe version of the given API to use. If not provided, the default version of the API will be used.)help--collectionTz5The name of the collection to specify the method for.)required	completerr!   z--raw
store_trueFzFor list commands, the response is flattened to return the items as a list rather than returning the list response verbatim. Use this flag to disable this behavior and return the raw response.)actiondefaultr!   z--apiz.The name of the API to get the attributes for.c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )MethodDynamicPositionalActionH   zA DynamicPositionalAction that adds flags for a given method to the parser.

Based on the value given for method, it looks up the valid fields for that
method call and adds those flags to the parser.
c                 Z   > UR                  S5      U l        [        [        U ]  " U0 UD6  g )Ndest)pop_destsuperr)   __init__)selfargskwargs	__class__s      r   r0   &MethodDynamicPositionalAction.__init__O   s*     F#DJ	
'7HH    c                 >   [        USS 5      n[        USS 5      nU(       d  [        R                  " SS5      e[        R                  " X2US9n[
        R                  " UUR                  S9n[        XU5      n[        XR                  U5        UR                  5       $ )Nr   api_versionr"   z<The collection name must be specified before the API method.)r8   )raw)r   c_excRequiredArgumentExceptionr
   	GetMethodr	   AutoArgumentGeneratorr9   	MethodRefsetattrr.   GenerateArgs)r1   	namespacemethod_namefull_collection_namer8   methodarg_generator
method_refs           r   r@   *MethodDynamicPositionalAction.GenerateArgsV   s    "9lDA)]D9K++

HJ J
  4,79F $99&>GmmMM9m<JIzz:.%%''r6   c                     [        X40 UD6$ r   )r    )r1   r   r   r3   s       r   Completions)MethodDynamicPositionalAction.Completionsj   s    69&99r6   )r.   )
__name__
__module____qualname____firstlineno____doc__r0   r@   rI   __static_attributes____classcell__)r4   s   @r   r)   r)   H   s    I((: :r6   r)   c                   $    \ rS rSrSrS rS rSrg)r>   n   a  Encapsulates a method specified on the command line with all its flags.

This makes use of an ArgumentGenerator to generate and parse all the flags
that correspond to a method. It provides a simple interface to the command so
the implementor doesn't need to be aware of which flags were added and
manually extract them. This knows which flags exist and what method fields
they correspond to.
c                 (    Xl         X l        X0l        g)zCreates the MethodRef.

Args:
  namespace: The argparse namespace that holds the parsed args.
  method: APIMethod, The method.
  arg_generator: arg_marshalling.AutoArgumentGenerator, The generator for
    this method.
N)rA   rD   rE   )r1   rA   rD   rE   s       r   r0   MethodRef.__init__x   s     NK&r6   c                 @   U R                   R                  nU R                   R                  U R                  5      nU R                   R	                  U R                  5      nU R                   R                  U R                  5      nU R                  R                  X!X4S9$ )z?Execute the method.

Returns:
  The result of the method call.
)r9   limit	page_size)rE   r9   CreateRequestrA   LimitPageSizerD   Call)r1   r9   requestrW   rX   s        r   r\   MethodRef.Call   s}     


 
 C  ..t~~>G$$T^^4E""++DNN;I;;GEOOr6   )rE   rD   rA   N)rK   rL   rM   rN   rO   r0   r\   rP    r6   r   r>   r>   n   s    '
Pr6   r>   N)rO   
__future__r   r   r   googlecloudsdk.callioper   r   r:   r   $googlecloudsdk.command_lib.util.apisr	   r
   r   r   r    ArgumentAPI_VERSION_FLAGCOLLECTION_FLAGRAW_FLAGAPI_REQUIRED_FLAGDynamicPositionalActionr)   objectr>   r_   r6   r   <module>rj      s     J &  ' ( 7 5 @ 91=; ==
,- 
 --!	@	B ==
F	 MM	9	; #:$5$M$M #:L!P !Pr6   