
                            S r SSKJr  SSKJr  SSKJr  SSKrSSK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SKJr  SSKJr  SSKJr  SSKJr   " S S\5      r " S S\5      r " S S\\R8                  S9rS3S jr " S S\5      r " S S\5      r  " S S\ 5      r! " S  S!\ 5      r"S" r#S# r$S$ r%S% r&S& r'S' r(S( r)S) r*S* r+S+ r,S, r- " S- S.\\R8                  S9r. " S/ S0\.5      r/ " S1 S2\.5      r0g)4zJHelpers for loading resource argument definitions from a yaml declaration.    )absolute_import)division)unicode_literalsN)base)concepts)	multitype)util)	arg_utils)registry)update_args)update_resource_args)yaml_command_schema_util)concept_parsers)presentation_specs)textc                   (    \ rS rSrSrSS jrS rSrg)	Arguments'   z>Everything about cli arguments are registered in this section.Nc           	         [         R                  R                  US5      U l        UR	                  S/ 5      nUR                  U R                  X5      5        U=(       d    0 nU Vs/ s H'  n[        R                  XBR	                  S5      5      PM)     snU l        UR	                  S5      (       a  [        UR	                  S5      5      OS U l
        UR	                  S/ 5      U l        g s  snf )Nadditional_arguments_hookparamsapi_versionlabelsexclude)r	   HookFromDatar   getextend_GetResourceDataYAMLArgumentr   Labelsr   r   )selfdatarequest_dataparams_data
param_datas        ;lib/googlecloudsdk/command_lib/util/apis/yaml_arg_schema.py__init__Arguments.__init__*   s    %)YY%7%7)&+D" ((8R(Kt,,T@A%2L &'%J 	j*:*:=*IJ%'DK 150B0B&(+,DK88Ir*DL's   '.C,c                 8   U=(       d    0 nUR                  S5      nU(       d  / $ / SQnU HT  nUR                  U5      nUc  M  UR                  U5      b%  [        R                  " SR                  U5      5      eXcU'   MV     UR                  S0 5      US'   U/$ )a  Gets the resource data from the arguments and request data.

This a temporary method to align the old and new schemas and should be
removed after b/272076207 is complete.

Args:
  data: arguments yaml data in command.
  request_data: request yaml data in command.

Returns:
  resource data with missing request params.

Raises:
  InvalidSchemaError: if the YAML command is malformed.
resource)resource_method_paramsparse_resource_into_requestuse_relative_namez][{}] is defined in both request and argument.param. Recommend only defining in argument.paramspecresource_spec)r   r	   InvalidSchemaErrorformat)r"   r#   r$   r+   moved_request_paramsrequest_paramparams          r'   r   Arguments._GetResourceData:   s       %2Lxx
#Hi
 .}-e		<<&2''006}0EG G #( . !)VR 8H_:    )r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r(   r   __static_attributes__ r7   r'   r   r   '   s    F+ (r7   r   c                       \ rS rSrSrS rSrg)r!   e   z)Everything about labels of GCP resources.c                     US   U l         g )N	api_fieldrC   )r"   r#   s     r'   r(   Labels.__init__h   s    +&DNr7   rD   N)r9   r:   r;   r<   r=   r(   r>   r?   r7   r'   r!   r!   e   s
    1'r7   r!   c                       \ rS rSrSr\S
S j5       r\\R                  S 5       5       r
\R                  S 5       r\R                  S 5       r\R                  S 5       rS	rg)r    l   zrRoot for generating all arguments from yaml data.

Requires all subclasses to contain Generate and Parse methods.
Nc                     UR                  S5      nU(       a  [        R                  X25      $ UR                  S5      (       a  [        R                  X5      $ [        R                  U5      $ )Ngroupr0   )r   ArgumentGroupr   YAMLConceptArgumentArgument)clsr#   r   rI   s       r'   r   YAMLArgument.FromDatar   sU    HHWE##E77xx   ))$<<T""r7   c                     g)z)List of api fields this argument maps to.Nr?   r"   s    r'   
api_fieldsYAMLArgument.api_fields}       r7   c                     g)zEWhether the argument with an api field is specified in the namespace.Nr?   r"   	namespaces     r'   IsApiFieldSpecified YAMLArgument.IsApiFieldSpecified   rS   r7   c                     g)z(Generates and returns the base argument.Nr?   r"   methodsshared_resource_flagss      r'   GenerateYAMLArgument.Generate   rS   r7   c                     g)zGParses namespace for argument's value and appends value to req message.Nr?   r"   methodmessagerV   group_requireds        r'   ParseYAMLArgument.Parse   rS   r7   r?   r8   )r9   r:   r;   r<   r=   classmethodr   propertyabcabstractmethodrQ   rW   r]   rd   r>   r?   r7   r'   r    r    l   s    
 # # 4  4 P P 3 3 R Rr7   r    )	metaclassc                 X   [        S U R                  5       R                  5        5       5      nU=(       a    [        R                  " U5      nXC;   a  gU(       a  S [
        R                   5       nOSnSn[        R                  " XV5       H  nSR                  Xt5      U;   d  M    g   g)aD  Provides whether or not the argument has been specified.

Args:
  namespace: user specified arguments
  arg_dest: str, normalize string of the argument name
  clearable: Boolean, True if param has clearable arguments
    such as clear, add, etc

Returns:
  Boolean, whether or not the argument is specified in the namespace
c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr8   )resource_utilNormalizeFormat).0keys     r'   	<genexpr>_IsSpecified.<locals>.<genexpr>   s%      64# ##C((4   #%Tc              3   8   #    U  H  oR                   v   M     g 7fr8   )value)ro   prefixs     r'   rq   rr      s     E2D||2D   r?   )noz{}_{}F)
setGetSpecifiedArgskeysrm   rn   r   Prefix	itertoolschainr2   )rV   arg_dest	clearablespecified_args_listdestupdate_prefixesnegative_prefixesrv   s           r'   _IsSpecifiedr      s      6++-2246 6 
	=m33H=$	 E+2D2DEOOCf~~f#':: D r7   c                      ^  \ rS rSrSr\SS j5       r   SU 4S jjr\S 5       r	\S 5       r
S rS rS	 rS
 rS rS rSS jrSS jrSrU =r$ )rJ      a  Encapsulates data used to generate argument groups.

Most of the attributes of this object correspond directly to the schema and
have more complete docs there.

Attributes:
  help_text: Optional help text for the group.
  required: True to make the group required.
  mutex: True to make the group mutually exclusive.
  hidden: True to make the group hidden.
  arg_name: The name of the argument that will be generated.
  clearable: True to automatically generate update flags such as `clear`
  settable: True to automatically generate arg_object flag to set the value
    of the whole argument argument group.
  arguments: The list of arguments in the group.
c                    UR                  SS5      (       a  [        R                  U5      nOSnUR                  SS5      (       a  [        R                  U5      nOSnU " UR                  S5      UR                  SS5      UR                  SS5      UR                  SS5      UR                  S	5      UR                  S
5      UR                  S5       Vs/ s H  n[        R                  XR5      PM     snUUS9	$ s  snf )zGets the arg group definition from the spec data.

Args:
  data: The group spec data.
  api_version: Request method api version.

Returns:
  ArgumentGroup, the parsed argument group.

Raises:
  InvalidSchemaError: if the YAML command is malformed.
settableFNr   	help_textrequiredmutexhiddenrC   arg_namer   )	r   r   r   r   rC   r   	argumentssettable_argclearable_arg)r   SettableArgumentForGroupr   ClearableArgumentForGroupr    )rM   r#   r   r   r   items         r'   r   ArgumentGroup.FromData   s     xx
E""-66t<llxxU##/88>mm((;'*e,hhw&xx%(((;'*%#xx131t  ((;13!# 3s   C=c
                    > [         [        U ]  5         Xl        X l        X0l        X@l        X`l        Xpl        Xl	        Xl
        XPl        g r8   )superrJ   r(   r   r   r   r   r   r   _settable_arg_clearable_arg
_api_field)r"   r   r   r   r   rC   r   r   r   r   	__class__s             r'   r(   ArgumentGroup.__init__   sA     
-')NMJKMN%'Or7   c                 f    / nU R                    H  nUR                  UR                  5        M      U$ r8   )r   r   rQ   )r"   rQ   args      r'   rQ   ArgumentGroup.api_fields   s-    J~~' r7   c                 |    U R                   (       a  U R                   $ [        R                  " U R                  5      $ )zDReturns api field that is the parent of all api fields in the group.)r   r
   GetSharedParentrQ   rP   s    r'   parent_api_fieldArgumentGroup.parent_api_field   s*     __&&t77r7   c                 N    U R                   =n=(       a    UR                  U5      $ r8   )r   rW   r"   rV   r   s      r'   _SettableIsSpecified"ArgumentGroup._SettableIsSpecified  s#    %%%CM3+B+B9+MMr7   c                 N    U R                   =n=(       a    UR                  U5      $ r8   )r   rW   r   s      r'   _ClearableIsSpecified#ArgumentGroup._ClearableIsSpecified  s#    &&&CNC,C,CI,NNr7   c                     U R                  U5      (       d  U R                  U5      (       a  gU R                   H  nUR                  U5      (       d  M    g   g)NTF)r   r   r   rW   r   s      r'   rW   !ArgumentGroup.IsApiFieldSpecified
  sN    !!),,""9--~~		 	 	+	+  r7   c                 ^    U R                   =(       a    U R                   R                  X5      $ )z;Returns the clear flag for the argument group if specified.)r   r]   rZ   s      r'   _GenerateClearFlag ArgumentGroup._GenerateClearFlag  s+     I((HJr7   c                 ^    U R                   =(       a    U R                   R                  X5      $ )z9Returns the set flag for the argument group if specified.)r   r]   rZ   s      r'   _GenerateSetFlagArgumentGroup._GenerateSetFlag  s+     H''GIr7   c                 4   S U R                    5       n[        R                  " SU R                  U R                  SU R
                   SU R                  R                   SSR                  U5       S3S9nUR                  U5        UR                  U5        U$ )	z<Returns the mutex group for the argument group if specified.c              3   h   #    U  H(  n[        U[        5      (       d  M  UR                  v   M*     g 7fr8   )
isinstancerL   r   )ro   r   s     r'   rq   4ArgumentGroup._GenerateMutexGroup.<locals>.<genexpr>!  s#      M .*S(2Ks   22TzSet the value of z by using flag [z] or flags [, ].)r   r   r   help)
r   r   rJ   r   r   r   r   r   joinAddArgument)r"   
base_groupset_flag	arg_namesmutex_groups        r'   _GenerateMutexGroup!ArgumentGroup._GenerateMutexGroup  s    M $MI $${{0 1""++, -		)$%R)K J'H%r7   c                    [         R                  " U R                  U R                  U R                  U R
                  S9nU R                   H#  nUR                  UR                  X5      5        M%     U R                  X5      =n(       a  UR                  U5        U R                  X5      =n(       a$  UR                  (       a  U R                  X65      $ U$ U$ )zGenerates and returns the base argument group.

Args:
  methods: list[registry.APIMethod], used to generate other arguments
  shared_resource_flags: [string], list of flags being generated elsewhere

Returns:
  The base argument group.
)r   r   r   r   )r   rJ   r   r   r   r   r   r   r]   r   r   r   )r"   r[   r\   r   r   
clear_flagr   s          r'   r]   ArgumentGroup.Generate1  s     ##jj4==t~~{{J ~~S\\'IJ  ,,WLLzLZ( ((HHxH			''
==r7   c                 V   [         R                  " X#U 5        U R                  (       a  U R                  R                  XX45        U R                  (       a  U R                  R                  XX45        U R
                   H(  nUR                  XX4=(       a    U R                  5        M*     g)a=  Sets argument group message values, if any, from the parsed args.

Args:
  method: registry.APIMethod, used to parse sub arguments.
  message: The API message, None for non-resource args.
  namespace: The parsed command line argument namespace.
  group_required: bool, if true, then parent argument group is required
N)r
   ClearUnspecifiedMutexFieldsr   rd   r   r   r   )r"   ra   rb   rV   rc   r   s         r'   rd   ArgumentGroup.ParseO  s{     ))'dC 
K 
v	J~~	ii,Lt}}M r7   )	r   r   r   r   r   r   r   r   r   r8   )	NFFFNNNNNT)r9   r:   r;   r<   r=   rf   r   r(   rg   rQ   r   r   r   rW   r   r   r   r]   rd   r>   __classcell__r   s   @r'   rJ   rJ      s    " " "H JO(,@D    8 8NO	J
I
$<N Nr7   rJ   c                      ^  \ rS rSrSr\S 5       rSSSSSSSS\R                  SSSSSSSSS4U 4S jjr	\
S 5       rS	 rS
 rS rS rS rSS jrSS jrSrU =r$ )rL   if  a;  Encapsulates data used to generate arguments.

Most of the attributes of this object correspond directly to the schema and
have more complete docs there.

Attributes:
  api_field: The name of the field in the request that this argument values
    goes.
  disable_unused_arg_check: Disables yaml_command_test check for unused
    arguments in static analysis.
  arg_name: The name of the argument that will be generated. Defaults to the
    api_field if not set.
  help_text: The help text for the generated argument.
  metavar: The metavar for the generated argument. This will be generated
    automatically if not provided.
  completer: A completer for this argument.
  is_positional: Whether to make the argument positional or a flag.
  type: The type to use on the argparse argument.
  choices: A static map of choice to value the user types.
  default: The default for the argument.
  fallback: A function to call and use as the default for the argument.
  processor: A function to call to process the value of the argument before
    inserting it into the request.
  required: True to make this a required flag.
  hidden: True to make the argument hidden.
  action: An override for the argparse action to use for this argument.
  repeated: False to accept only one value when the request field is actually
    repeated.
  generate: False to not generate this argument. This can be used to create
    placeholder arg specs for defaults that don't actually need to be
    generated.
  clearable: True to automatically generate update flags such as `clear`,
    `update`, `remove`, and `add`
c                    UR                  S5      nUR                  S5      nUR                  SU5      nU(       d  [        R                  " S5      eUR                  S5      nU(       a  UOSU-   nUR                  S5      (       a,  UR                  S5      (       a  [        R                  " S	5      e US
   nUR                  S5      nU " S0 SU_SU_S
U_SUR                  S5      _S[        R                  R                  US5      _SU_S[        R                  " U5      _SU(       a'  U V	s/ s H  n	[        R                  " U	5      PM     sn	OS_SUR                  S[        R                  5      _S[        R                  R                  US5      _S[        R                  R                  US5      _SUR                  SS5      _SUR                  SS5      _S[        R                  " UR                  S5      U5      _SUR                  S5      _SU_SUR                  SS5      _6$ ! [         a    [        R                  " S5      ef = fs  sn	f )zGets the arg definition from the spec data.

Args:
  data: The spec data.

Returns:
  Argument, the parsed argument.

Raises:
  InvalidSchemaError: if the YAML command is malformed.
rC   disable_unused_arg_checkr   z<An argument must have at least one of [api_field, arg_name].is_positional--defaultfallbackz8An argument may have at most one of [default, fallback].r   z An argument must have help_text.choicesmetavar	completertypeN	processorr   Fr   actionrepeatedr   r?   )r   r	   r1   KeyErrorr   r   	ParseTypeChoicer
   UNSPECIFIEDParseAction)
rM   r#   rC   r   r   r   	flag_namer   r   ds
             r'   r   Argument.FromData  sK    %I#xx(BCxx
I.H##
HJ JHH_-M)thIxx	txx
33##
DF FH{#i hhy!G   #	
 ))$$T;7 $ ^^D! 6=1AQ1$ I$9$9: ##D*5 ))$$T;7 *e, xx%(  2I> *%  ":!" ((;.#   H##$FGGH 2s   4H/ 0 I/!INFTc                   > [         [        U ]  5         Xl        UU l        X l        X0l        X@l        XPl        X`l	        Xpl
        Xl        Xl        Xl        Xl        Xl        Xl        Xl        Xl        UU l        UU l        g r8   )r   rL   r(   rC   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   generater   )r"   rC   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                      r'   r(   Argument.__init__  st    & 
(D"$N$<D!MNLN&ILLMNMKKMDMDNr7   c                 B    U R                   (       a  U R                   /$ / $ r8   rD   rP   s    r'   rQ   Argument.api_fields  s    #~~DNN525r7   c                     U R                   (       d  g[        U[        R                  " U R                  5      U R
                  S9$ )NF)rV   r   r   )rQ   r   rm   rn   r   r   rU   s     r'   rW   Argument.IsApiFieldSpecified  s5    ??..t}}=.." "r7   c                 t    U(       a1  U R                   (       a   [        R                  " XR                   5      $ g)z.Gets apitools field associated with api_field.N)rC   r
   GetFieldFromMessage)r"   rb   s     r'   	_GetFieldArgument._GetField  s#    4>>**7NNCCr7   c                    U(       a  U R                   (       d  gU R                  US   R                  5       5      nU H  nU R                  UR                  5       5      nUR                  UR                  :w  d6  UR                  UR                  :w  d  UR
                  UR
                  :w  d  Mr  SR                  S U 5       5      n[        R                  " SU R                    SU S35      e   U$ )z;Gets apitools field associated with api_field from methods.Nr   r   c              3   T   #    U  H  oR                  5       R                  v   M      g 7fr8   )GetRequestTyper9   ro   ra   s     r'   rq   0Argument._GetFieldFromMethods.<locals>.<genexpr>  s!      "D;B!!#,,7s   &(z&Unable to generate flag for api field z,. Found non equivalent fields in messages: [r   )	rC   r   r   namevariantr   r   r	   r1   )r"   r[   fieldra   other_fieldmessage_namess         r'   _GetFieldFromMethodsArgument._GetFieldFromMethods  s    $..NN71:4467ENN6#8#8#:;k
**((
(
--;..
.
..K00
0		 "D;B"D D%%4T^^4D E99FrKL 	L  Lr7   c                 @    [         R                  R                  X5      $ )z4Creates update flags generator using aptiools field.)r   UpdateBasicArgumentGeneratorFromArgData)r"   r   s     r'   _GenerateUpdateFlagsArgument._GenerateUpdateFlags  s    33??LLr7   c                 d    U R                  U5      nU R                  U5      R                  X5      $ z@Parses update flags and returns modified apitools message field.)r   r   rd   )r"   rV   rb   r   s       r'   _ParseUpdateArgsFromNamespace&Argument._ParseUpdateArgsFromNamespace  s,    NN7#E$$U+11)EEr7   c                     U R                  U5      nU R                  (       a&  U(       a  U R                  U5      R                  5       $ [        R
                  " X05      $ )zGenerates and returns the base argument.

Args:
  methods: list[registry.APIMethod], used to generate other arguments.
  shared_resource_flags: [string], list of flags being generated elsewhere.

Returns:
  The base argument.
)r   r   r   r]   r
   GenerateFlag)r"   r[   r\   r   s       r'   r]   Argument.Generate  sH     %%g.E~~%&&u-6688##E00r7   c           	      :   AAU R                   c  gU R                  (       aI  U R                  X25      nU R                  U5      (       a!  [        R
                  " X R                   U5        g[        R                  " X0R                  U R                  S9nUc  gU R                  U5      n[        R                  " XeU R                  U R                  [        R                  R                  U R                   5      S9n[        R
                  " X R                   U5        g)H  Sets the argument message value, if any, from the parsed args.

Args:
  method: registry.APIMethod, used to parse other arguments.
  message: The API message, None for non-resource args.
  namespace: The parsed command line argument namespace.
  group_required: bool, whether parent argument group is required.
    Unused here.
N)r   )r   r   r   )rC   r   r   rW   r
   SetFieldInMessageGetFromNamespacer   r   r   ConvertValuer   r   r	   r   ToChoiceMapr   )r"   ra   rb   rV   rc   ru   r   s          r'   rd   Argument.Parse(  s     	~~~~00De		!	!)	,	,##G^^UC&&==4==:E}NN7#E""t}}''57E ?r7   )r   rC   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   r   )r9   r:   r;   r<   r=   rf   r   r
   r   r(   rg   rQ   rW   r   r   r   r   r]   rd   r>   r   r   s   @r'   rL   rL   f  s    !F 2 2l ! ,,(-%%N 6 6"(MF
1"@ @r7   rL   c                   D   ^  \ rS rSrSr\S 5       r  SU 4S jjrSrU =r	$ )r   iI  zFEncapsulates data used to generate arg_object flag for argument group.c                     US   nUS   nU " UUUR                  S5      UR                  SS5      UR                  SS5      [        R                  R                  USS	9S
9$ ! [          a    [        R                  " S5      ef = f)1Gets the arg group definition from the spec data.rC   r   z=Settable argument group must have api_field and arg_name set.r   r   Fr   T)disable_key_description)rC   r   r   r   r   arg_type)r   r	   r1   r   	ArgObjectr   rM   r#   rC   r   s       r'   r   !SettableArgumentForGroup.FromDataL  s    K{#ij!h
 ((;'*e,xx%(((t(L 	  K##
IK KKs   
A" "!Bc           	      2   > [         [        U ]  UUUUUUS9  g )NrC   r   r   r   r   r   )r   r   r(   )r"   rC   r   r   r   r   r  r   s          r'   r(   !SettableArgumentForGroup.__init___  s*    	
"D2 3 r7   r?   )NFFN)
r9   r:   r;   r<   r=   rf   r   r(   r>   r   r   s   @r'   r   r   I  s,    N $ DI&*	 	r7   r   c                   J   ^  \ rS rSrSr\S 5       rSU 4S jjrSS jrSr	U =r
$ )	r   ik  zEncapsulates data used to generate a clearable flag.

Clearable flag is specifically for clearing a message field corresponding to
the argument group.
c           	           US   nUS   nU " UUSUR                  SS5      S9$ ! [          a    [        R                  " S5      ef = f)r  rC   r   z>Clearable argument group must have api_field and arg_name set.Fr   )rC   r   r   r   )r   r	   r1   r   r  s       r'   r   "ClearableArgumentForGroup.FromDatar  sm    L{#ij!h
 xx%(	 	  L##
JL LLs	   
% !Ac           	         > [         [        U ]  USR                  [        R
                  R                  R                  [        R                  " U5      45      SU S3UU[        S9  g )N-zSet z back to default value.r  )r   r   r(   r   r   r|   CLEARru   rm   	KebabCasebool)r"   rC   r   r   r   r   s        r'   r(   "ClearableArgumentForGroup.__init__  sg    	
#T3%%++$$X.01 #:; 4 	r7   c                     [         R                  " X0R                  5      (       a!  [         R                  " X R                  5        g g r8   )r
   r  r   ResetFieldInMessagerC   r`   s        r'   rd   ClearableArgumentForGroup.Parse  s.    !!)]];;##G^^< <r7   r?   )FFr   )r9   r:   r;   r<   r=   rf   r   r(   rd   r>   r   r   s   @r'   r   r   k  s+       
= =r7   r   c                 X    U R                    Vs/ s H  oR                  PM     sn$ s  snf r8   )
attributesr   )r0   attrs     r'   _GetAttributeNamesr%    s$     - 8 8	9 8)) 8	99	9   'c                 v    U R                    Vs/ s H  nU R                  U5      (       d  M  UPM     sn$ s  snf )z$Get the anchor for the resource arg.)r#  IsLeafAnchor)r0   as     r'   _GetAnchorsr*    s;    "-- 
,-''* - 
, , 
,s   66c                     [        XU5      (       a  g[        U 5       H1  nUR                  UR                  5      n[        XU5      (       d  M1    g   g)zEChecks if any of the resource anchors are specified in the namespace.TF)r   r*  r   r   )r0   rV   attribute_to_dest_mappresentation_namer   anchorr   s          r'   _IsAnchorSpecifiedr/    sN    
 )	:: M*f$((5HI33 + 
r7   c                     U(       a  SOSnSR                  S [        U 5       5       5      n[        R                  " X#5      $ )a  Name of the resource arg.

Name is used to prefix attribute flags (if needed) and determine the
location where the resource is specified in the namespace.

For presentation name foo-bar, the expected format is...
  1. `foo-bar` if anchor is not positional
  2. `FOO_BAR` if anchor is positional

Args:
  resource_spec: The resource spec.
  repeated: True if the resource is repeated.

Returns:
  The name of the resource arg.
      z-or-c              3   8   #    U  H  oR                   v   M     g 7fr8   )r   )ro   r)  s     r'   rq   '_GetPresentationName.<locals>.<genexpr>  s     @%?VV%?rw   )r   r*  r   	Pluralize)r0   r   countr   s       r'   _GetPresentationNamer7    s5    " !Q%	@[%?@	@$		$$r7   c                     [        S U  5       5      n[        U5      S:  a  [        R                  " S5      eU(       a  UR	                  5       $ g)Nc              3   @   #    U  H  oR                  5       v   M     g 7fr8   )IsListr   s     r'   rq   _GetIsList.<locals>.<genexpr>  s     6gFgs   r2  zMethods used to generate YAMLConceptArgument cannot contain both list and non-list methods. Update the list of methods to only use list or non-list methods.F)ry   lenr	   r1   pop)r[   is_lists     r'   
_GetIsListr?    sJ    6g66'\A

!
!	$% %
 ;;=r7   c                     0 nUR                  5        Ha  u  p4U c  SnOR[        U [        5      (       a'  U  Vs/ s H  n[        R                  " XF5      PM     nnO[        R                  " X@5      nXRU'   Mc     U$ s  snf )a  Generates a map of message fields to respective resource attribute value.

  Ex: If you have a resource arg...
    projects/foo/locations/us-central1/instances/bar

  ...and you want to set the `parent` field in the request message to the
  resource's relative name, you would use this function like...
    _GetResourceMap(ref, {'parent': '__relative_name__'})

  ...and it would return...
    {'parent': 'projects/foo/locations/us-central1/instances/bar'}

Args:
  ref: Parsed resource arg.
  resource_method_params: A dict of message field name to resource attribute
    name.

Returns:
  A dict of message field name to resource attribute value.
N)itemsr   listr	   FormatResourceAttrStr)refr,   message_resource_mapmessage_field_name	param_strvaluesrs          r'   _GetResourceMaprJ    s    * '='C'C'E#
{f	C		BEF#Q**98#fFf)))9f/5+, (F 
	 Gs    A:c                     U R                  SS5      (       a  [        R                  " U S   5      $ [        R                  " U S   5      $ )z>Returns the fallthrough string for the given fallthrough data.r   Fr   )r   rm   PositionalFormatFlagNameFormat)fallthrough_datas    r'   _FallthroughFlagFromDatarO    sC    /511))*::*FGG''(8(DEEr7   c                     0 nU =(       d    0 R                  5        H$  u  p U  Vs/ s H  n[        U5      PM     nnXAU'   M&     U$ s  snf )z<Generate a map of command-level fallthroughs from yaml data.)rA  rO  )fallthroughs_datacommand_level_fallthroughs	attr_namefallthroughfallthroughs_lists        r'    _GenerateFallthroughsMapFromDatarV    s^    !'8'>B&E&E&G"i,=?,=[ 2+>,=  ?,=y) 'H
 
$#	?s   Ac           
         U=(       d    / n0 nU R                  5       nUR                  UR                  5        VVs0 s H$  u  pxX;   d  M  U[        R                  " U5      /_M&     snn5        [
        R                  " XSU5        U$ s  snnf )a`  Generate a map of fallthroughs for the given argument.

Generates a map of a resource attribute name and the flag it should default
to for the ConceptParser. The shared (ignored) flags have to be added
manually since they are not added by the ConceptParser.

Args:
  arg_fallthroughs: A dict of fallthroughs for the given argument.
  attribute_to_flag_map: The names of the attributes in the
    resource spec.
  shared_resource_flags: Flags that are already generated elsewhere.
  presentation_flag_name: The name of the anchor argument.

Returns:
  A dictionary of resource attributes to fallthrough flags
)copyupdaterA  rm   rM  r   UpdateFallthroughsMap)	arg_fallthroughsattribute_to_flag_mapr\   presentation_flag_namesharedrR  full_arg_fallthroughsr$  flags	            r'   _GenerateFullFallthroughsMapra    s    & !&B&!*//1-335 5*$ 1d]))$/005  
 '' :OQ	## s   B
B
c                     X=(       d    / -   nUR                  5        VVs0 s H  u  pEXS;   d  M  US_M     snn$ s  snnf )a  Generate a map of flags that should be ignored.

Flags are either ignored because they have already been generated elsewhere
or because the command explicitly removed them.

Args:
  shared_resource_flags: Flags that are already generated elsewhere
  ignored_flags: Flags that have been explicitly removed in the command
  attribute_to_flag_map: Attributes mapped to flag names

Returns:
  A map of flags to ignore to an empty string.
 )rA  )r\   ignored_flagsr\  all_ignored_flagsr$  r`  s         r'   _GenerateIgnoredFlagsMaprf  (  sN     $'BC!6!<!<!>
!>:4		" dBh!>
  
s   ;;c                     [        [        S [        R                  R	                  5        5       5      5      nU  Vs/ s H  nX1;   d  M
  X   PM     nnX$-   $ s  snf )z.Returns all the flags that need to be removed.c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr8   )rm   rM  )ro   r`  s     r'   rq   #_AllRemovedFlags.<locals>.<genexpr>@  s%      42$ ""4((2rs   )rB  ry   r   IGNORED_FIELDSrH  )removed_attrsatribute_to_flag_mapignoredr$  removed_flagss        r'   _AllRemovedFlagsro  >  sl     4))0024 4 5' .;'-:T		% ! ]  ' 
	  's   	A	Ac                   L   \ rS rSrSr\SS j5       r       SS jr\\	R                  S 5       5       r\\	R                  S 5       5       r\\	R                  S 5       5       r\\	R                  S	 5       5       r\\	R                  S
 5       5       r\\	R                  S 5       5       r\\	R                  S 5       5       r\	R                  S 5       r\	R                    SS j5       r\	R                  SS j5       r\	R                  S 5       r\S 5       rSS jrSS jrS rSrg)rK   iI  ay  Encapsulate data used to generate and parse all resource args.

YAMLConceptArgument is parent class that parses data and standardizes
the interface (abstract base class) for YAML resource arguments by
requiring methods Generate, Parse, and ParseResourceArg. All of the
methods on YAMLConceptArgument are private helper methods for YAML
resource arguments to share minor logic.
Nc                    U(       d  g US   nUS   n0 SUR                  S5      _SUR                  SS5      _SUR                  S5      _SUR                  S5      _SUR                  S5      _S	UR                  S	0 5      _S
UR                  S
5      _SUR                  S5      _SUR                  S0 5      _SUR                  SS5      _SUR                  SS5      _SUR                  SS5      _SUR                  S5      _SUR                  SS5      _SU_SUR                  SS5      _nSUS   ;   a  [        X440 UD6$ [        X440 UD6$ )Nr0   r   r   is_parent_resourceFis_primary_resourcern  r   rR  display_name_hookrequest_id_fieldr,   r-   Tr.   override_resource_collectionr   r   request_api_versionr   	resources)r   YAMLMultitypeResourceArgumentYAMLResourceArgument)rM   r#   r   r0   r   kwargss         r'   r   YAMLConceptArgument.FromDataS  s   )M[!I/2dhh';UC 	txx(=> 	/2	
 	DHHZ( 	%dhh("'. 	TXX&9: 	DHH%78 	!$((+CR"H 	&txx)4(1 	TXX&94@ 	'*E)3  	DHHZ(!" 	DHHZ/#$ 	{%& 	TXXk51'F, d?++*=NvNN!-EfEEr7   c                    Xpl         X l        X0l        XPl        X`l        U=(       d    / U l        [        U5      U l        U
=(       d    UR                  S5      U l	        U=(       d    0 U l
        Xl        Xl        Xl        Xl        UU l        UU l        US   U l        UR                  S5      U l        U	(       a%  [&        R(                  R+                  U	5      U l        g S U l        g )Nru  r   plural_name)flag_name_override
group_help_is_positionalrr  rs  _removed_attrsrV  rR  r   ru  r,   r-   r.   rv  	_requiredr   r   r   _plural_namer	   r   FromPathrt  )r"   r#   r  r   rn  rr  rs  r   rR  rt  ru  r,   r-   r.   rv  r   r   r   unused_kwargss                      r'   r(   YAMLConceptArgument.__init__u  s     ' O'02'-2D&F"'$D# -L9K0LD"8">BD'B$.(D%NDMDN VDI/D 2C		,- 	HL 	r7   c                     g)z@"Get registry.APICollection based on collection and api_version.Nr?   rP   s    r'   
collectionYAMLConceptArgument.collection       	r7   c                     g)z?Get registry.APICollection based on collection and api_version.Nr?   rP   s    r'   collectionsYAMLConceptArgument.collections  r  r7   c                     g)z'Get the anchors from the resource spec.Nr?   rP   s    r'   anchorsYAMLConceptArgument.anchors  r  r7   c                     g)z&Whether the resource arg is multitype.Nr?   rP   s    r'   r   YAMLConceptArgument.multitype  r  r7   c                     g)z)Names of attributes in the resource spec.Nr?   rP   s    r'   attribute_names#YAMLConceptArgument.attribute_names  r  r7   c                     g8Returns a map of attribute name to normalized flag name.Nr?   rP   s    r'   r\  )YAMLConceptArgument.attribute_to_flag_map  r  r7   c                     gr  r?   rP   s    r'   rd  !YAMLConceptArgument.ignored_flags  r  r7   c                     g)z8Determines if this resource arg is the primary resource.Nr?   r"   resource_collections     r'   IsPrimaryResource%YAMLConceptArgument.IsPrimaryResource       	r7   c                     g)z/Generate the resource arg for the given method.Nr?   )r"   ra   r]  r  r\   r  s         r'   GenerateResourceArg'YAMLConceptArgument.GenerateResourceArg  s    
 	r7   c                     g)z9Parses the resource ref from namespace (no update flags).Nr?   )r"   rV   rc   s      r'   ParseResourceArg$YAMLConceptArgument.ParseResourceArg  r  r7   c                     g)z3Get the anchor argument name for the resource spec.Nr?   )r"   r  is_list_methods      r'   GetPresentationFlagName+YAMLConceptArgument.GetPresentationFlagName  r  r7   c                 n    U R                   (       a#  [        U R                   R                  5       5      $ / $ )z:Where the resource arg is mapped into the request message.)r,   rB  r{   rP   s    r'   rQ   YAMLConceptArgument.api_fields  s,     ""$--22455ir7   c                 v    U R                   b  U R                   $ U R                  U5      nU=(       a    U(       + $ )a^  Determines if the resource arg is positional.

Args:
  resource_collection: APICollection | None, collection associated with
    the api method. None if a methodless command.
  is_list_method: bool | None, whether command is associated with list
    method. None if methodless command.

Returns:
  bool, whether the resource arg anchor is positional
)r  r  )r"   r  r  rs  s       r'   IsPositional YAMLConceptArgument.IsPositional  s<     &   001DE5~#55r7   c                 V    U R                   b  U R                   $ U R                  U5      $ )zDetermines if the resource arg is required.

Args:
  resource_collection: APICollection | None, collection associated with
    the api method. None if a methodless command.

Returns:
  bool, whether the resource arg is required
)r  r  r  s     r'   
IsRequiredYAMLConceptArgument.IsRequired  s*     ~~!^^!!"566r7   c                     U H1  nU R                  UR                  5      (       d  M%  UR                  s  $    U(       a  US   R                  $ S $ )Nr   )r  resource_argument_collection)r"   r[   ra   s      r'   _GetMethodCollection(YAMLConceptArgument._GetMethodCollection   sI    			 C C	D	D222  9@WQZ44ITIr7   )r  r  r  r  r   rR  rt  r  r  rr  rs  r   rv  r-   r   ru  r,   r.   r8   )NNFNNNNNNTTFNFFNNNNr   NF)r9   r:   r;   r<   r=   rf   r   r(   rg   rh   ri   r  r  r  r   r  r\  rd  r  r  r  r  rQ   r  r  r  r>   r?   r7   r'   rK   rK   I  s    F FB JN=A9=8<HLDI8=N@ 	  	 	  	 	  	 	  	 	  	 	  	 	  	 	 	 DH-1	 	 	 	 	 	  6(7Jr7   rK   c                   B  ^  \ rS rSrSr\S 5       rSU 4S jjr\S 5       r	\S 5       r
\S 5       r\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       rS rS r SS jr  SS jrSS jrS rS r SS jrS rSS jrSS jrSrU =r$ )rz  i
  DEncapsulates the spec for the resource arg of a declarative command.c                 *    U(       d  gU " US4SU0UD6$ )a  Create a resource argument with no command-level information configured.

Given just the reusable resource specification (such as attribute names
and fallthroughs, it can be used to generate a ResourceSpec. Not suitable
for adding directly to a command as a solo argument.

Args:
  data: the yaml resource definition.
  request_api_version: str, api version of request collection.
  **kwargs: attributes outside of the resource spec

Returns:
  YAMLResourceArgument with no group help or flag name information.
Nrw  r?   )rM   r#   rw  r{  s       r'   FromSpecData!YAMLResourceArgument.FromSpecData  s"      tTM/BMfMMr7   c           
        > [         [        U ]
  " X40 UD6  US   U l        UR	                  SU5      U l        US   U l        UR	                  SS5      U l        U R                   H[  nXPR                  ;  d  M  [        R                  " SR                  XPR                  SR                  U R                  5      5      5      e   g )Nr  r   r#  disable_auto_completersTznRemoved flag [{}] for resource arg [{}] references an attribute that does not exist. Valid attributes are [{}]r   )r   rz  r(   _full_collection_namer   _api_versionattribute_data_disable_auto_completersr  r  r	   r1   r2   r   r   )r"   r#   r  rw  r{  removedr   s         r'   r(   YAMLResourceArgument.__init__"  s    	
.tJ6J!%l!3D 0CDD|,D$(HH-F$MD!&&	,,	,%%==CVDIId.B.B$C>EF 	F 'r7   c                 T    [         R                  " U R                  U R                  S9$ )Nr   )r   GetAPICollectionr  r  rP   s    r'   r  YAMLResourceArgument.collection8  s(    $$""0A0AC Cr7   c                     U R                   /$ r8   )r  rP   s    r'   r   YAMLResourceArgument.collections=  s    OOr7   c                     gr  r?   rP   s    r'   r   YAMLResourceArgument.multitypeA  s    r7   c                 ,    [        U R                  5      $ r8   r*  _resource_specrP   s    r'   r  YAMLResourceArgument.anchorsE      t**++r7   c                 ,    [        U R                  5      $ r8   r%  r  rP   s    r'   r  $YAMLResourceArgument.attribute_namesI      d1122r7   c           	         [         R                  " U R                  U R                  R                  5      n[         R
                  " U R                  R                  4U R                  U R                  R                  U R                  U R                  U R                  S.U Vs0 s H  o"R                  U_M     snD6$ s  snf )&Resource spec generated from the YAML.)resource_namer   r  r~  r   )r   ParseAttributesFromDatar  r  detailed_paramsResourceSpec	full_namer   r   r  r  r  parameter_name)r"   r#  	attributes      r'   r  #YAMLResourceArgument._resource_specM  s     11T__<<>J   !!MiiOO// $ = =%%
 ))M AK
K
9##Y.

KM M Ls   #B>c                 |    U R                   (       a  U R                   $ [        U R                  U R                  5      $ r8   r  r7  r  r   rP   s    r'   r-  &YAMLResourceArgument.presentation_namec  0     $$$!$"5"5t}}EEr7   c                 |    U R                  S[        R                  " U R                  5      S0 S5      R                  $ )-Returns a map of attribute name to flag name.FN_GeneratePresentationSpecrm   rM  r-  attribute_to_args_maprP   s    r'   r\  *YAMLResourceArgument.attribute_to_flag_mapl  <     ))}++D,B,BCb$ r7   c                     U R                   R                  5        VVs0 s H  u  pU[        R                  " U5      _M     snn$ s  snnf r8   r\  rA  rm   rn   r"   r$  r`  s      r'   _attribute_to_flag_dest_map0YAMLResourceArgument._attribute_to_flag_dest_mapw  J     44::<<JD 	m++D11<     #Ac                 B    [        U R                  U R                  5      $ r  ro  r  r\  rP   s    r'   rd  "YAMLResourceArgument.ignored_flags~       D//1K1KLLr7   c                 |    UR                   R                  S5      u  n  n[        R                  " X R                  S9$ )N.r  )r  
rpartitionr   r  r  )r"   r  parent_collection_s       r'   _GetParentResource'YAMLResourceArgument._GetParentResource  s<    1;;FFsKq!$$'8'8: :r7   c                    U R                   (       d  U R                   b  gU(       a  U R                  (       a  gU R                  (       a  U R                  U5      nUR                  U R
                  :w  aW  U R                   (       aE  [        R                  " SR                  U R                  UR                  U R
                  5      5      egU R                  (       aq  U R                  UR                  :w  aW  U R                   (       aE  [        R                  " SR                  U R                  UR                  U R                  5      5      egg)  Determines whether this resource arg is primary for a given method.

Primary indicates that this resource arg represents the resource the api
is fetching, updating, or creating

Args:
  resource_collection: APICollection | None, collection associated with
    the api method. None if a methodless command.

Returns:
  bool, true if this resource arg corresponds with the given method
    collection
FTzaCollection names do not match for resource argument specification [{}]. Expected [{}], found [{}]z]API versions do not match for resource argument specification [{}]. Expected [{}], found [{}])rs  rv  rr  r  r  r  r	   r1   r2   r   r  r   r  s     r'   r  &YAMLResourceArgument.IsPrimaryResource  s    ##(@(@(L $"C"C 334GH$$(B(BB		!	!%%.VDII2<<..01 	1
 0<<<		!	!%%.VDII2>>%%'( 	(
 r7   c           
      x    [         R                  " UU R                  USU0 U=(       d    0 EUEU R                  S9$ NF)r  prefixesr   flag_name_overridesplural)r   ResourcePresentationSpecr  r   r"   is_requiredr]  r  ignored_flag_mapr  s         r'   r  .YAMLResourceArgument._GeneratePresentationSpec  sG     66N 2 8bN=MN}} r7   c                     [        U R                  U R                  XB5      n[        UU R                  U R                  5      nU R                  U R                  U5      UX7U5      n[        R                  " U/US9$ z2Generates only the resource arg (no update flags).)rR  	ra  rR  r\  rf  rd  r  r  r   ConceptParser	r"   ra   r]  r  r\   r  rR  r  presentation_specs	            r'   r  (YAMLResourceArgument.GenerateResourceArg      
 ">''"""7
 0""$
 66!7j: ((	#=? ?r7   c                    [        U R                  UU R                  U R                  U R                  5      nU(       d  U(       d  g[
        R                  " UR                  U R                  5      nU=(       a    UR                  5       $ a  Parses the resource ref from namespace (no update flags).

Args:
  namespace: The argparse namespace.
  group_required: bool, whether parent argument group is required

Returns:
  The parsed resource ref or None if no resource arg was generated for this
  method.
N)	r/  r  r  r-  r   r
   r  CONCEPTSrd   )r"   rV   rc   anchor_specifiedresults        r'   r  %YAMLResourceArgument.ParseResourceArg  sr    $ *(( N''D224F $flln$r7   c                     U R                   (       d  g[        U R                  UU R                  U R                  U R
                  5      $ r  rQ   r/  r  r  r-  r   rU   s     r'   rW   (YAMLResourceArgument.IsApiFieldSpecified  s>    ??(( r7   c                 r    U R                  X5      (       + nU(       a  SU R                  -   $ U R                  $ aj  Get the anchor argument name for the resource spec.

Args:
  resource_collection: APICollection | None, collection associated with
    the api method. None if a methodless command.
  is_list_method: bool | None, whether command is associated with list
    method. None if methodless command.

Returns:
  string, anchor in flag format ie `--foo-bar` or `FOO_BAR`
r   r  r-  r"   r  r  anchor_arg_is_flags       r'   r  ,YAMLResourceArgument.GetPresentationFlagName  E     "..- -  	t%%%;#'#9#9;r7   c                 B    [         R                  R                  XX#5      $ z6Creates update flags generator using aptiools message.r   UpdateResourceArgumentGeneratorr   r"   r  r  r\   s       r'   r   )YAMLResourceArgument._GenerateUpdateFlags  $      ??KK>J Jr7   c                 B    U R                  X5      R                  X45      $ r   r   rd   r"   r  r  rV   rb   s        r'   r   2YAMLResourceArgument._ParseUpdateArgsFromNamespace  %     $$--2U9-FGr7   c                     U R                  U5      n[        U5      nU R                  (       a   U R                  X4U5      R	                  5       $ U R                  UU R                  X45      SUU R                  S9$ )zGenerates and returns resource argument.

Args:
  methods: list[registry.APIMethod], used to generate other arguments.
  shared_resource_flags: [string], list of flags being generated elsewhere.

Returns:
  Resource argument.
Nr]  r  r\   r  r  r?  r   r   r]   r  r  r  r"   r[   r\   r  r  s        r'   r]   YAMLResourceArgument.Generate#  s     33G<(N~~&&
/DFFNhjQ %%
!%!=!=!"3! 5__ & & &r7   c                    U R                   (       a5  U R                  U=(       a    UR                  UR                  5       X25      nOU R	                  X45      nU R
                  (       + =(       d    U R                  U5      nU R                  (       a  U(       d  U(       d  g[        R                  " XQU[        XPR                  5      U R                  U R                  U R                  U=(       a    UR                  5      S9  g)r  NrE  ru  r.   rs  r   r   r  r:  r  rQ   rW   r-   r
   ParseResourceIntoMessagerJ  r,   ru  r.   r  r"   ra   rb   rV   rc   rD  user_specifieds          r'   rd   YAMLResourceArgument.Parse<  s     ~~..

8V88
--/
c
 !!)<c OOBt77	B ++C &&W,S2M2MN..00 22:v::<=r7   )r  r  r  r  r8   r  r   ) r9   r:   r;   r<   r=   rf   r  r(   rg   r  r  r   r  r  r  r-  r\  r  rd  r  r  r  r  r  rW   r  r   r   r]   rd   r>   r   r   s   @r'   rz  rz  
  sF   LN N(F, C C     , , 3 3 M M* F F     M M:
+^ 8<
 EI-1?.%@	;* HLJG&2= =r7   rz  c                   ,  ^  \ rS rSrSrSU 4S jjr\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       rS r SS jr  SS jrSS jrS rS r SS jrS rSS jrSS jrSrU =r$ )ry  i^  r  c           	         > [         [        U ]
  " X40 UD6  / U l        UR	                  S/ 5       H;  nU R                  R                  [        R                  UUU R                  S95        M=     g )Nrx  )rr  )	r   ry  r(   
_resourcesr   appendrz  r  rr  )r"   r#   r  rw  r{  resource_datar   s         r'   r(   &YAMLMultitypeResourceArgument.__init__a  sp    	
'7$"$ DO+r2
oo

+
+!!%!8!8 , :; 3r7   c                     g r8   r?   rP   s    r'   r  (YAMLMultitypeResourceArgument.collectionm      r7   c                 X    U R                    Vs/ s H  oR                  PM     sn$ s  snf r8   )r@  r  )r"   r+   s     r'   r  )YAMLMultitypeResourceArgument.collectionsq  s"    04@H@@@r&  c                     g)NTr?   rP   s    r'   r   'YAMLMultitypeResourceArgument.multitypeu  rF  r7   c                 ,    [        U R                  5      $ r8   r  rP   s    r'   r  %YAMLMultitypeResourceArgument.anchorsy  r  r7   c                 ,    [        U R                  5      $ r8   r  rP   s    r'   r  -YAMLMultitypeResourceArgument.attribute_names}  r  r7   c                 |    U R                   (       a  U R                   $ [        U R                  U R                  5      $ r8   r  rP   s    r'   r-  /YAMLMultitypeResourceArgument.presentation_name  r  r7   c                 |    U R                  S[        R                  " U R                  5      S0 S5      R                  $ )r  FNr  rP   s    r'   r\  3YAMLMultitypeResourceArgument.attribute_to_flag_map  r  r7   c                     U R                   R                  5        VVs0 s H  u  pU[        R                  " U5      _M     snn$ s  snnf r8   r  r  s      r'   r  9YAMLMultitypeResourceArgument._attribute_to_flag_dest_map  r  r  c                 B    [        U R                  U R                  5      $ r  r  rP   s    r'   rd  +YAMLMultitypeResourceArgument.ignored_flags  r  r7   c                    / nU R                    HS  nUR                  (       d$  [        SR                  U R                  5      5      eUR                  UR                  5        MU     [        R                  " U R                  /UQ76 $ )r  zIdisable_auto_completers must be True for multitype resource argument [{}])	r@  r  
ValueErrorr2   r   rA  r  r   MultitypeResourceSpec)r"   resource_specssub_resources      r'   r  ,YAMLMultitypeResourceArgument._resource_spec  sr     N22 <<BF499<MO 	OL778 ( **499F~FFr7   c                 D   U R                   (       d  U R                   b  gU R                   H  nUR                  U5      (       d  M    g   U R                   (       aE  [        R                  " SR                  U R                  UR                  UR                  5      5      eg)r  FTzCollection names do not align with resource argument specification [{}]. Expected [{} version {}], and no contained resources matched.)	rs  r@  r  r	   r1   r2   r   r  r   )r"   r  r[  s      r'   r  /YAMLMultitypeResourceArgument.IsPrimaryResource  s     ##(@(@(L		'	'(;	<	< ( ##%vii,66!-- /0 0 r7   c           
      x    [         R                  " UU R                  USU0 UEU=(       d    0 EU R                  S9$ r  )r   !MultitypeResourcePresentationSpecr  r   r
  s         r'   r  7YAMLMultitypeResourceArgument._GeneratePresentationSpec  sG     ??N/N4F4L"N}} r7   c                     [        U R                  U R                  XB5      n[        UU R                  U R                  5      nU R                  U R                  U5      UX7U5      n[        R                  " U/US9$ r  r  r  s	            r'   r  1YAMLMultitypeResourceArgument.GenerateResourceArg  r  r7   c                 @   [        U R                  UU R                  U R                  U R                  5      nU(       d  U(       d  g[
        R                  " UR                  U R                  5      nU=(       a    UR                  5       nU=(       a    UR                  $ r  )
r/  r  r  r-  r   r
   r  r  rd   r  )r"   rV   rc   is_anchor_specifiedr  parsed_results         r'   r  .YAMLMultitypeResourceArgument.ParseResourceArg  s    $ -(( ~''D224F -v||~M1]111r7   c                     U R                   (       d  g[        U R                  UU R                  U R                  U R
                  5      $ r  r  rU   s     r'   rW   1YAMLMultitypeResourceArgument.IsApiFieldSpecified  s<    ??Y(($*@*@ r7   c                 r    U R                  X5      (       + nU(       a  SU R                  -   $ U R                  $ r   r!  r"  s       r'   r  5YAMLMultitypeResourceArgument.GetPresentationFlagName  r%  r7   c                 B    [         R                  R                  XX#5      $ r'  r(  r*  s       r'   r   2YAMLMultitypeResourceArgument._GenerateUpdateFlags.  r,  r7   c                 B    U R                  X5      R                  X45      $ r   r.  r/  s        r'   r   ;YAMLMultitypeResourceArgument._ParseUpdateArgsFromNamespace4  r1  r7   c                     U R                  U5      n[        U5      nU R                  (       a   U R                  X4U5      R	                  5       $ U R                  UU R                  X45      S UU R                  S9$ )Nr3  r4  r5  s        r'   r]   &YAMLMultitypeResourceArgument.Generate:  s    33G<(N~~&&
/DFFNhjQ %%
!%!=!=!"3! 5__ & & &r7   c                    U R                   (       a5  U R                  U=(       a    UR                  UR                  5       X25      nOU R	                  X45      nU R
                  (       + =(       d    U R                  U5      nU R                  (       a  U(       d  U(       d  g [        R                  " XQU[        XPR                  5      U R                  U R                  U R                  U=(       a    UR                  5      S9  g )Nr8  r9  r;  s          r'   rd   #YAMLMultitypeResourceArgument.ParseJ  s    ~~..

8V88
--/
c
 !!)<c OOBt77	B ++C &&W,S2M2MN..00 22:v::<=r7   )r@  r8   r  r   )r9   r:   r;   r<   r=   r(   rg   r  r  r   r  r  r-  r\  r  rd  r  r  r  r  r  rW   r  r   r   r]   rd   r>   r   r   s   @r'   ry  ry  ^  s,   L
;   A A   , , 3 3 F F     M M G G@ 8<
 EI-1?.2B;* HLJG& = =r7   ry  )F)1r=   
__future__r   r   r   rh   r}   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr   r   r	   rm   $googlecloudsdk.command_lib.util.apisr
   r   r   r   r   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.core.utilr   objectr   r!   ABCMetar    r   rJ   rL   r   r   r%  r*  r/  r7  r?  rJ  rO  rV  ra  rf  ro  rK   rz  ry  r?   r7   r'   <module>r|     s    Q &  ' 
  ( 5 6 B : 9 < E Q D G ); ;|'V ' R6S[[  RFBsNL sNl`@| `@Fx D&= &=R:, %.BF	$$@,!~J,#++ ~JBQ=. Q=h
B=$7 B=r7   