
                         "   d Z ddlmZ ddlmZ ddlmZ ddlZddl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 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  G d de      Z G d de      Z G d deej8                        Zd3dZ G d de      Z G d de      Z  G d de       Z! G d  d!e       Z"d" Z#d# Z$d$ Z%d% Z&d& Z'd' Z(d( Z)d) Z*d* Z+d+ Z,d, Z- G d- d.eej8                        Z. G d/ d0e.      Z/ G d1 d2e.      Z0y)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                       e Zd ZdZddZd Zy)	Argumentsz>Everything about cli arguments are registered in this section.Nc           	         t         j                  j                  |d      | _        |j	                  dg       }|j                  | j                  ||             |xs i }|D cg c]'  }t        j                  ||j	                  d            ) c}| _        |j	                  d      rt        |j	                  d            nd | _
        |j	                  dg       | _        y c c}w )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__zArguments.__init__*   s    %)YY%7%7)&+D" ((8R(Kt,,T<@A%2L &'%J 	j,*:*:=*IJ%'DK 150B&(+,DK88Ir*DL's   #,C!c                    |xs i }|j                  d      }|sg S g d}|D ]P  }|j                  |      }||j                  |      $t        j                  dj                  |            |||<   R |j                  di       |d<   |gS )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   zArguments._GetResourceData:   s       %2Lxx
#Hi
 .}-e		<<&2''006}0EG G #( . !)VR 8H_:    N)__name__
__module____qualname____doc__r'   r    r4   r&   r   r   '   s    F+ (r4   r   c                       e Zd ZdZd Zy)r    z)Everything about labels of GCP resources.c                     |d   | _         y )N	api_fieldr=   )r!   r"   s     r&   r'   zLabels.__init__h   s    +&DNr4   N)r6   r7   r8   r9   r'   r:   r4   r&   r    r    e   s
    1'r4   r    c                       e Zd ZdZedd       Zeej                  d               Z	ej                  d        Z
ej                  d        Zej                  d        Zy)	r   zvRoot for generating all arguments from yaml data.

  Requires all subclasses to contain Generate and Parse methods.
  Nc                     |j                  d      }|rt        j                  ||      S |j                  d      rt        j                  ||      S t        j                  |      S )Ngroupr.   )r   ArgumentGroupr   YAMLConceptArgumentArgument)clsr"   r   rA   s       r&   r   zYAMLArgument.FromDatar   sV    HHWE##E;77xx  ))$<<T""r4   c                      y)z)List of api fields this argument maps to.Nr:   r!   s    r&   
api_fieldszYAMLArgument.api_fields}       r4   c                      y)zEWhether the argument with an api field is specified in the namespace.Nr:   r!   	namespaces     r&   IsApiFieldSpecifiedz YAMLArgument.IsApiFieldSpecified   rI   r4   c                      y)z(Generates and returns the base argument.Nr:   r!   methodsshared_resource_flagss      r&   GeneratezYAMLArgument.Generate   rI   r4   c                      y)zGParses namespace for argument's value and appends value to req message.Nr:   r!   methodmessagerL   group_requireds        r&   ParsezYAMLArgument.Parse   rI   r4   r5   )r6   r7   r8   r9   classmethodr   propertyabcabstractmethodrH   rM   rR   rX   r:   r4   r&   r   r   l   s    
 # # 4  4 P P 3 3 R Rr4   r   )	metaclassc                 :   t        d | j                         j                         D              }|xr t        j                  |      }||v ry|rd t
        j                  D        }nd}d}t        j                  ||      D ]  }dj                  ||      |v s y y)aT  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   F   K   | ]  }t        j                  |        y wr5   )resource_utilNormalizeFormat).0keys     r&   	<genexpr>z_IsSpecified.<locals>.<genexpr>   s#      64# ##C(4   !Tc              3   4   K   | ]  }|j                     y wr5   )value)rb   prefixs     r&   rd   z_IsSpecified.<locals>.<genexpr>   s     E2Dv||2D   r:   )noz{}_{}F)
setGetSpecifiedArgskeysr`   ra   r   Prefix	itertoolschainr0   )rL   arg_dest	clearablespecified_args_listdestupdate_prefixesnegative_prefixesrh   s           r&   _IsSpecifiedrw      s      6++-2246 6 
	=m33H=$	  E+2D2DEOO1BCf~~fd#':: D r4   c                        e Zd ZdZedd       Z	 	 	 d fd	Zed        Zed        Z	d Z
d Zd Zd	 Zd
 Zd ZddZddZ xZS )rB   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                    |j                  dd      rt        j                  |      }nd}|j                  dd      rt        j                  |      }nd} | |j                  d      |j                  dd      |j                  dd      |j                  dd      |j                  d	      |j                  d
      |j                  d      D cg c]  }t        j                  ||       c}||	      S c c}w )a  Gets 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.
    settableFNrr   	help_textrequiredmutexhiddenr=   arg_namer   )	r{   r|   r}   r~   r=   r   	argumentssettable_argclearable_arg)r   SettableArgumentForGroupr   ClearableArgumentForGroupr   )rE   r"   r   r   r   items         r&   r   z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   C4c
                     t         t        |           || _        || _        || _        || _        || _        || _        || _	        |	| _
        || _        y r5   )superrB   r'   r{   r|   r}   r~   r   r   _settable_arg_clearable_arg
_api_field)r!   r{   r|   r}   r~   r=   r   r   r   r   	__class__s             r&   r'   zArgumentGroup.__init__   sS     
-')DNDMDJDKDMDN%D'DDOr4   c                 b    g }| j                   D ]  }|j                  |j                          |S r5   )r   r   rH   )r!   rH   args      r&   rH   zArgumentGroup.api_fields   s-    J~~' r4   c                 p    | j                   r| j                   S t        j                  | j                        S )zDReturns api field that is the parent of all api fields in the group.)r   r
   GetSharedParentrH   rG   s    r&   parent_api_fieldzArgumentGroup.parent_api_field   s*     __&&t77r4   c                 D    | j                   x}xr |j                  |      S r5   )r   rM   r!   rL   r   s      r&   _SettableIsSpecifiedz"ArgumentGroup._SettableIsSpecified  s#    %%%CM3+B+B9+MMr4   c                 D    | j                   x}xr |j                  |      S r5   )r   rM   r   s      r&   _ClearableIsSpecifiedz#ArgumentGroup._ClearableIsSpecified  s#    &&&CNC,C,CI,NNr4   c                     | j                  |      s| j                  |      ry| j                  D ]  }|j                  |      s y y)NTF)r   r   r   rM   r   s      r&   rM   z!ArgumentGroup.IsApiFieldSpecified
  sE    !!),""9-~~		 	 	+  r4   c                 V    | j                   xr | j                   j                  ||      S )z;Returns the clear flag for the argument group if specified.)r   rR   rO   s      r&   _GenerateClearFlagz ArgumentGroup._GenerateClearFlag  s.     I((2GHJr4   c                 V    | j                   xr | j                   j                  ||      S )z9Returns the set flag for the argument group if specified.)r   rR   rO   s      r&   _GenerateSetFlagzArgumentGroup._GenerateSetFlag  s.     H''1FGIr4   c                 8   d | j                   D        }t        j                  d| j                  | j                  d| j
                   d| j                  j                   ddj                  |       d      }|j                  |       |j                  |       |S )	z<Returns the mutex group for the argument group if specified.c              3   V   K   | ]!  }t        |t              s|j                   # y wr5   )
isinstancerD   r   )rb   r   s     r&   rd   z4ArgumentGroup._GenerateMutexGroup.<locals>.<genexpr>!  s"      M .*S(2Ks   ))TzSet the value of z by using flag [z] or flags [, ].)r}   r|   r~   help)
r   r   rB   r|   r~   r   r   r   joinAddArgument)r!   
base_groupset_flag	arg_namesmutex_groups        r&   _GenerateMutexGroupz!ArgumentGroup._GenerateMutexGroup  s    M $MI $${{0 1""++, -		)$%R)K J'H%r4   c                    t        j                  | j                  | j                  | j                  | j
                        }| j                  D ]#  }|j                  |j                  ||             % | j                  ||      x}r|j                  |       | j                  ||      x}r |j                  r| j                  ||      S |S |S )a  Generates 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   rB   r}   r|   r{   r~   r   r   rR   r   r   r   )r!   rP   rQ   r   r   
clear_flagr   s          r&   rR   zArgumentGroup.Generate1  s     ##jj4==t~~{{J ~~S\\'3HIJ  ,,W6KLLzLZ( ((2GHHxH			''
H==r4   c                 @   t        j                  |||        | j                  r| j                  j                  ||||       | j                  r| j                  j                  ||||       | j
                  D ]$  }|j                  ||||xr | j                         & y)aU  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   rX   r   r   r|   )r!   rU   rV   rL   rW   r   s         r&   rX   zArgumentGroup.ParseO  s     ))'9dC 
NK 
vw	>J~~	iiN,Lt}}M r4   r5   )	NFFFNNNNNT)r6   r7   r8   r9   rY   r   r'   rZ   rH   r   r   r   rM   r   r   r   rR   rX   __classcell__r   s   @r&   rB   rB      s    " " "H JO(,@D    8 8NO	J
I
$<Nr4   rB   c                        e Zd ZdZed        Zddddddddej                  dddddddddf fd	Ze	d        Z
d Zd	 Zd
 Zd Zd ZddZddZ xZS )rD   ay  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                 j   |j                  d      }|j                  d      }|j                  d|      }|st        j                  d      |j                  d      }|r|nd|z   }|j                  d      r&|j                  d      rt        j                  d	      	 |d
   }|j                  d      } | di d|d|d
|d|j                  d      dt        j                  j                  |d      d|dt        j                  |      d|r#|D 	cg c]  }	t        j                  |	       c}	ndd|j                  dt        j                        dt        j                  j                  |d      dt        j                  j                  |d      d|j                  dd      d|j                  dd      dt        j                  |j                  d      |      d|j                  d      d|d|j                  dd      S # t        $ r t        j                  d      w xY wc c}	w )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.
    r=   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repeatedrr   r:   )r   r	   r/   KeyErrorr   r   	ParseTypeChoicer
   UNSPECIFIEDParseAction)
rE   r"   r=   r   r   r   	flag_namer{   r   ds
             r&   r   zArgument.FromData  sE    %I#xx(BCxx
I.H##
HJ JHH_-M)thIxx	txx
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   H H0H-NFTc                 &   t         t        |           || _        || _        || _        || _        || _        || _        || _	        || _
        || _        |	| _        |
| _        || _        || _        || _        || _        || _        || _        || _        y r5   )r   rD   r'   r=   r   r   r{   r   r   r   r   r   r   r   r   r|   r~   r   r   generaterr   )r!   r=   r   r{   r   r   r   r   r   r   r   r   r|   r~   r   r   r   r   rr   r   s                      r&   r'   zArgument.__init__  s    & 
(D"$DN$<D!DMDNDLDN&DDIDLDLDMDNDMDKDKDMDMDNr4   c                 8    | j                   r| j                   gS g S r5   r>   rG   s    r&   rH   zArgument.api_fields  s    #~~DNN525r4   c                     | j                   syt        |t        j                  | j                        | j
                        S )NF)rL   rq   rr   )rH   rw   r`   ra   r   rr   rK   s     r&   rM   zArgument.IsApiFieldSpecified  s5    ??..t}}=.." "r4   c                 `    |r,| j                   r t        j                  || j                         S y)z.Gets apitools field associated with api_field.N)r=   r
   GetFieldFromMessage)r!   rV   s     r&   	_GetFieldzArgument._GetField  s%    4>>**7DNNCCr4   c                    |r| j                   sy| j                  |d   j                               }|D ]  }| j                  |j                               }|j                  |j                  k7  s3|j                  |j                  k7  s|j
                  |j
                  k7  sndj                  d |D              }t        j                  d| j                    d| d       |S )z;Gets apitools field associated with api_field from methods.Nr   r   c              3   P   K   | ]  }|j                         j                     y wr5   )GetRequestTyper6   rb   rU   s     r&   rd   z0Argument._GetFieldFromMethods.<locals>.<genexpr>  s$      "D;BF!!#,,7s   $&z&Unable to generate flag for api field z,. Found non equivalent fields in messages: [r   )	r=   r   r   namevariantr   r   r	   r/   )r!   rP   fieldrU   other_fieldmessage_namess         r&   _GetFieldFromMethodsz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  Lr4   c                 B    t         j                  j                  | |      S )z4Creates update flags generator using aptiools field.)r   UpdateBasicArgumentGeneratorFromArgData)r!   r   s     r&   _GenerateUpdateFlagszArgument._GenerateUpdateFlags  s    33??eLLr4   c                 f    | j                  |      }| j                  |      j                  ||      S z@Parses update flags and returns modified apitools message field.)r   r   rX   )r!   rL   rV   r   s       r&   _ParseUpdateArgsFromNamespacez&Argument._ParseUpdateArgsFromNamespace  s.    NN7#E$$U+11)WEEr4   c                     | j                  |      }| j                  r!|r| j                  |      j                         S t	        j
                  ||       S )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   rr   r   rR   r
   GenerateFlag)r!   rP   rQ   r   s       r&   rR   zArgument.Generate  sJ     %%g.E~~%&&u-6688##E400r4   c           	      0   ~~| j                   y| j                  rE| j                  ||      }| j                  |      r!t	        j
                  || j                   |       yt	        j                  || j                  | j                        }|y| j                  |      }t	        j                  ||| j                  | j                  t        j                  j                  | j                               }t	        j
                  || j                   |       y)d  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   )r=   rr   r   rM   r
   SetFieldInMessageGetFromNamespacer   r   r   ConvertValuer   r   r	   r   ToChoiceMapr   )r!   rU   rV   rL   rW   rg   r   s          r&   rX   zArgument.Parse(  s     	~~~~00GDe		!	!)	,##GT^^UC&&4==4==:E}NN7#E""ut}}''57E ?r4   r5   r   )r6   r7   r8   r9   rY   r   r
   r   r'   rZ   rH   rM   r   r   r   r   rR   rX   r   r   s   @r&   rD   rD   f  s    !F 2 2l ! ,,(-%%N 6 6"(MF
1"@r4   rD   c                   8     e Zd ZdZed        Z	 	 d fd	Z xZS )r   zFEncapsulates data used to generate arg_object flag for argument group.c                    	 |d   }|d   } | |||j                  d      |j                  dd      |j                  dd      t        j                  j                  |d	      
      S # t         $ r t        j                  d      w xY w)1Gets the arg group definition from the spec data.r=   r   z=Settable argument group must have api_field and arg_name set.r{   r|   Fr~   T)disable_key_description)r=   r   r{   r|   r~   arg_type)r   r	   r/   r   	ArgObjectr   rE   r"   r=   r   s       r&   r   z!SettableArgumentForGroup.FromDataL  s    K{#ij!h
 ((;'*e,xx%(((t(L 	  K##
IK KKs   
A( (Bc                 8    t         t        |   ||||||       y )Nr=   r   r{   r|   r~   r   )r   r   r'   )r!   r=   r   r{   r|   r~   r   r   s          r&   r'   z!SettableArgumentForGroup.__init___  s*    	
"D2 3 r4   )NFFN)r6   r7   r8   r9   rY   r   r'   r   r   s   @r&   r   r   I  s,    N $ DI&*	 	r4   r   c                   <     e Zd ZdZed        Zd fd	ZddZ xZS )r   zEncapsulates data used to generate a clearable flag.

  Clearable flag is specifically for clearing a message field corresponding to
  the argument group.
  c           	          	 |d   }|d   } | ||d|j                  dd            S # t         $ r t        j                  d      w xY w)r   r=   r   z>Clearable argument group must have api_field and arg_name set.Fr~   )r=   r   r|   r~   )r   r	   r/   r   r   s       r&   r   z"ClearableArgumentForGroup.FromDatar  sm    L{#ij!h
 xx%(	 	  L##
JL LLs	   
( Ac           	          t         t        |   |dj                  t        j
                  j                  j                  t        j                  |      f      d| d||t               y )N-zSet z back to default value.r   )r   r   r'   r   r   rn   CLEARrg   r`   	KebabCasebool)r!   r=   r   r|   r~   r   s        r&   r'   z"ClearableArgumentForGroup.__init__  sg    	
#T3%%++$$X.01 #:; 4 	r4   c                     t        j                  || j                        r!t        j                  || j                         y y r5   )r
   r   r   ResetFieldInMessager=   rT   s        r&   rX   zClearableArgumentForGroup.Parse  s/    !!)T]];##GT^^< <r4   )FFr   )	r6   r7   r8   r9   rY   r   r'   rX   r   r   s   @r&   r   r   k  s&       
=r4   r   c                 T    | j                   D cg c]  }|j                   c}S c c}w r5   )
attributesr   )r.   attrs     r&   _GetAttributeNamesr     s&     - 8 8	9 8$)) 8	99	9   %c                 b    | j                   D cg c]  }| j                  |      r| c}S c c}w )z$Get the anchor for the resource arg.)r   IsLeafAnchor)r.   as     r&   _GetAnchorsr     s;    "-- 
,-''* - 
, , 
,s   ,c                     t        |||      ryt        |       D ],  }|j                  |j                        }t        |||      s, y y)zEChecks if any of the resource anchors are specified in the namespace.TF)rw   r   r   r   )r.   rL   attribute_to_dest_mappresentation_namerr   anchorr   s          r&   _IsAnchorSpecifiedr    sM    
 ).	: M*f$((5HIx3 + 
r4   c                 |    |rdnd}dj                  d t        |       D              }t        j                  ||      S )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   4   K   | ]  }|j                     y wr5   )r   )rb   r   s     r&   rd   z'_GetPresentationName.<locals>.<genexpr>  s     @%?QVV%?ri   )r   r   r   	Pluralize)r.   r   countr   s       r&   _GetPresentationNamer
    s7    " !Q%	@[%?@	@$	t	$$r4   c                     t        d | D              }t        |      dkD  rt        j                  d      |r|j	                         S y)Nc              3   <   K   | ]  }|j                           y wr5   )IsListr   s     r&   rd   z_GetIsList.<locals>.<genexpr>  s     6gFgs   r  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)rk   lenr	   r/   pop)rP   is_lists     r&   
_GetIsListr    sJ    6g66'\A

!
!	$% %
 ;;=r4   c                     i }|j                         D ]Y  \  }}| d}nJt        | t              r$| D cg c]  }t        j                  ||       }}nt        j                  ||       }|||<   [ |S c c}w )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&   _GetResourceMapr    s    * '='C'C'E#)
{f	C	BEF#Q**9a8#fF)))S9f/5+, (F 
	 Gs   A1c                     | j                  dd      rt        j                  | d         S t        j                  | d         S )z>Returns the fallthrough string for the given fallthrough data.r   Fr   )r   r`   PositionalFormatFlagNameFormat)fallthrough_datas    r&   _FallthroughFlagFromDatar!    s@    /51))*::*FGG''(8(DEEr4   c                     i }| xs i j                         D ]"  \  }} | D cg c]  }t        |       }}|||<   $ |S c c}w )z<Generate a map of command-level fallthroughs from yaml data.)r  r!  )fallthroughs_datacommand_level_fallthroughs	attr_namefallthroughfallthroughs_lists        r&    _GenerateFallthroughsMapFromDatar(    sd    !'8'>B&E&E&G"i",=?,=[ 2+>,=  ?,=y) 'H
 
$#	?s   >c           
         |xs g }i }| j                         }|j                  |j                         D ci c]   \  }}||v r|t        j                  |      g" c}}       t        j                  |||       |S c c}}w )ax  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updater  r`   r  r   UpdateFallthroughsMap)	arg_fallthroughsattribute_to_flag_maprQ   presentation_flag_namesharedr$  full_arg_fallthroughsr   flags	            r&   _GenerateFullFallthroughsMapr3    s    & !&B&!*//1-335 5*$ ]))$/005  
 '' "8:OQ	## s   %A=
c                 p    || xs g z   }|j                         D ci c]  \  }}||v r|d c}}S c c}}w )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.
   )r  )rQ   ignored_flagsr.  all_ignored_flagsr   r2  s         r&   _GenerateIgnoredFlagsMapr8  (  sT     $'<'BC!6!<!<!>
!>:4	"	" Bh!>
  
s   2c                     t        t        d t        j                  j	                         D                    }| D cg c]  }||v r||    }}||z   S c c}w )z.Returns all the flags that need to be removed.c              3   F   K   | ]  }t        j                  |        y wr5   )r`   r  )rb   r2  s     r&   rd   z#_AllRemovedFlags.<locals>.<genexpr>@  s#      42$ ""4(2re   )r  rk   r   IGNORED_FIELDSr  )removed_attrsatribute_to_flag_mapignoredr   removed_flagss        r&   _AllRemovedFlagsr@  >  sp     4))0024 4 5' .;'-:T	%	% 4 ]  ' 
=	  's   Ac                   8   e Zd ZdZedd       Z	 	 	 	 	 	 	 ddZeej                  d               Z
eej                  d               Zeej                  d               Zeej                  d               Zeej                  d	               Zeej                  d
               Zeej                  d               Zej                  d        Zej                  	 	 dd       Zej                  dd       Zej                  d        Zed        ZddZddZd Zy)rC   a  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                    |sy |d   }|d   }i d|j                  d      d|j                  dd      d|j                  d      d|j                  d      d|j                  d      d	|j                  d	i       d
|j                  d
      d|j                  d      d|j                  di       d|j                  dd      d|j                  dd      d|j                  dd      d|j                  d      d|j                  dd      d|d|j                  dd      }d|d   v rt        ||fi |S t        ||fi |S )Nr.   r{   r   is_parent_resourceFis_primary_resourcer?  r   r$  display_name_hookrequest_id_fieldr*   r+   Tr,   override_resource_collectionr|   r   request_api_versionrr   	resources)r   YAMLMultitypeResourceArgumentYAMLResourceArgument)rE   r"   r   r.   r{   kwargss         r&   r   z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Er4   c                    || _         || _        || _        || _        || _        |xs g | _        t        |      | _        |
xs |j                  d      | _	        |xs i | _
        || _        || _        || _        || _        || _        || _        |d   | _        |j                  d      | _        |	r%t&        j(                  j+                  |	      | _        y d | _        y )NrF  r   plural_name)flag_name_override
group_help_is_positionalrC  rD  _removed_attrsr(  r$  r   rF  r*   r+   r,   rG  	_requiredr   rr   r   _plural_namer	   r   FromPathrE  )r!   r"   rP  r   r?  rC  rD  r   r$  rE  rF  r*   r+   r,   rG  r|   r   rr   unused_kwargss                      r&   r'   zYAMLConceptArgument.__init__u  s     'D DO'D0D2D'-2D&F"'$D# -L9K0LD"8">BD'BD$.D(DD%DNDMDN VDI/D 2C		,- 	HL 	r4   c                      y)z@"Get registry.APICollection based on collection and api_version.Nr:   rG   s    r&   
collectionzYAMLConceptArgument.collection       	r4   c                      y)z?Get registry.APICollection based on collection and api_version.Nr:   rG   s    r&   collectionszYAMLConceptArgument.collections  rY  r4   c                      y)z'Get the anchors from the resource spec.Nr:   rG   s    r&   anchorszYAMLConceptArgument.anchors  rY  r4   c                      y)z&Whether the resource arg is multitype.Nr:   rG   s    r&   r   zYAMLConceptArgument.multitype  rY  r4   c                      y)z)Names of attributes in the resource spec.Nr:   rG   s    r&   attribute_namesz#YAMLConceptArgument.attribute_names  rY  r4   c                      y8Returns a map of attribute name to normalized flag name.Nr:   rG   s    r&   r.  z)YAMLConceptArgument.attribute_to_flag_map  rY  r4   c                      yrb  r:   rG   s    r&   r6  z!YAMLConceptArgument.ignored_flags  rY  r4   c                      y)z8Determines if this resource arg is the primary resource.Nr:   r!   resource_collections     r&   IsPrimaryResourcez%YAMLConceptArgument.IsPrimaryResource       	r4   c                      y)z/Generate the resource arg for the given method.Nr:   )r!   rU   r/  rO  rQ   rP  s         r&   GenerateResourceArgz'YAMLConceptArgument.GenerateResourceArg  s    
 	r4   c                      y)z9Parses the resource ref from namespace (no update flags).Nr:   )r!   rL   rW   s      r&   ParseResourceArgz$YAMLConceptArgument.ParseResourceArg  ri  r4   c                      y)z3Get the anchor argument name for the resource spec.Nr:   )r!   rg  is_list_methods      r&   GetPresentationFlagNamez+YAMLConceptArgument.GetPresentationFlagName  ri  r4   c                 d    | j                   r#t        | j                   j                               S g S )z:Where the resource arg is mapped into the request message.)r*   r  rm   rG   s    r&   rH   zYAMLConceptArgument.api_fields  s,     ""$--22455ir4   c                 b    | j                   | j                   S | j                  |      }|xr | S )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
    )rQ  rh  )r!   rg  ro  rD  s       r&   IsPositionalz YAMLConceptArgument.IsPositional  s<     &   001DE5~#55r4   c                 T    | j                   | j                   S | j                  |      S )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
    )rS  rh  rf  s     r&   
IsRequiredzYAMLConceptArgument.IsRequired  s*     ~~!^^!!"566r4   c                     |D ]+  }| j                  |j                        s|j                  c S  |r|d   j                  S d S )Nr   )rh  resource_argument_collection)r!   rP   rU   s      r&   _GetMethodCollectionz(YAMLConceptArgument._GetMethodCollection   sF    			 C C	D222  9@WQZ44ITIr4   r5   )NNFNNNNNNTTFNFFNNNNr   NF)r6   r7   r8   r9   rY   r   r'   rZ   r[   r\   rX  r[  r]  r   r`  r.  r6  rh  rk  rm  rp  rH   rs  ru  rx  r:   r4   r&   rC   rC   I  s    F FB JN=A9=8<HLDI8=N@ 	  	 	  	 	  	 	  	 	  	 	  	 	  	 	 	 DH-1	 	 	 	 	 	  6(7Jr4   rC   c                   *    e Zd ZdZed        Zd fd	Zed        Zed        Z	ed        Z
ed        Zed        Zed	        Zed
        Zed        Zed        Zed        Zd Zd Z	 ddZ	 	 ddZddZd Zd Z	 ddZd ZddZddZ xZS )rK  DEncapsulates the spec for the resource arg of a declarative command.c                      |sy | |dfd|i|S )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.
    NrH  r:   )rE   r"   rH  rL  s       r&   FromSpecDataz!YAMLResourceArgument.FromSpecData  s"      tTM/BMfMMr4   c           
         t        t        | 
  ||fi | |d   | _        |j	                  d|      | _        |d   | _        |j	                  dd      | _        | j                  D ]Y  }|| j                  vst        j                  dj                  || j                  dj                  | j                                     y )NrX  r   r   disable_auto_completersTznRemoved flag [{}] for resource arg [{}] references an attribute that does not exist. Valid attributes are [{}]r   )r   rK  r'   _full_collection_namer   _api_versionattribute_data_disable_auto_completersrR  r`  r	   r/   r0   r   r   )r!   r"   rP  rH  rL  removedr   s         r&   r'   zYAMLResourceArgument.__init__"  s    	
.tZJ6J!%l!3D 0CDD|,D$(HH-F$MD!&&	,,	,%%==CVDIId.B.B$C>EF 	F 'r4   c                 X    t        j                  | j                  | j                        S )Nr   )r   GetAPICollectionr  r  rG   s    r&   rX  zYAMLResourceArgument.collection8  s(    $$""0A0AC Cr4   c                     | j                   gS r5   )rX  rG   s    r&   r[  z YAMLResourceArgument.collections=  s    OOr4   c                      yrz  r:   rG   s    r&   r   zYAMLResourceArgument.multitypeA  s    r4   c                 ,    t        | j                        S r5   r   _resource_specrG   s    r&   r]  zYAMLResourceArgument.anchorsE      t**++r4   c                 ,    t        | j                        S r5   r   r  rG   s    r&   r`  z$YAMLResourceArgument.attribute_namesI      d1122r4   c           	      ~   t        j                  | j                  | j                  j                        }t        j
                  | j                  j                  f| j                  | j                  j                  | j                  | j                  | j                  d|D ci c]  }|j                  | c}S c c}w )&Resource spec generated from the YAML.)resource_namer   r  rN  r   )r   ParseAttributesFromDatar  rX  detailed_paramsResourceSpec	full_namer   r   r  rT  rQ  parameter_name)r!   r   	attributes      r&   r  z#YAMLResourceArgument._resource_specM  s     11T__<<>J   !!MiiOO// $ = =%%
 ))M AK
K
99##Y.

KM M Ls   !B:c                 r    | j                   r| j                   S t        | j                  | j                        S r5   rO  r
  r  r   rG   s    r&   r  z&YAMLResourceArgument.presentation_namec  0     $$$!$"5"5t}}EEr4   c                 z    | j                  dt        j                  | j                        di d      j                  S )-Returns a map of attribute name to flag name.FN_GeneratePresentationSpecr`   r  r  attribute_to_args_maprG   s    r&   r.  z*YAMLResourceArgument.attribute_to_flag_mapl  <     ))}++D,B,BCb$ r4   c                     | j                   j                         D ci c]  \  }}|t        j                  |       c}}S c c}}w r5   r.  r  r`   ra   r!   r   r2  s      r&   _attribute_to_flag_dest_mapz0YAMLResourceArgument._attribute_to_flag_dest_mapw  L     44::<<JD$ 	m++D11<      Ac                 B    t        | j                  | j                        S r  r@  rR  r.  rG   s    r&   r6  z"YAMLResourceArgument.ignored_flags~       D//1K1KLLr4   c                     |j                   j                  d      \  }}}t        j                  || j                        S )N.r  )r  
rpartitionr   r  r  )r!   rg  parent_collection_s       r&   _GetParentResourcez'YAMLResourceArgument._GetParentResource  s>    1;;FFsKq!$$t'8'8: :r4   c                 N   | j                   s| j                   y|r| j                  ry| j                  r| j                  |      }|j                  | j
                  k7  rQ| j                   rDt        j                  dj                  | j                  |j                  | j
                              y| j                  rj| j                  |j                  k7  rQ| j                   rDt        j                  dj                  | j                  |j                  | j                              yy)  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 [{}])rD  rG  rC  r  r  r  r	   r/   r0   r   r  r   rf  s     r&   rh  z&YAMLResourceArgument.IsPrimaryResource  s    ##(@(@(L $"C"C 334GH$$(B(BB		!	!%%.VDII2<<..01 	1
 0<<<		!	!%%.VDII2>>%%'( 	(
 r4   c           
      r    t        j                  || j                  |d|i |xs i || j                        S NF)rP  prefixesr|   flag_name_overridesplural)r   ResourcePresentationSpecr  r   r!   is_requiredr/  rO  ignored_flag_maprP  s         r&   r  z.YAMLResourceArgument._GeneratePresentationSpec  sG     66N 2 8bN=MN}} r4   c                     t        | j                  | j                  ||      }t        || j                  | j                        }| j                  | j                  |      ||||      }t        j                  |g|      S z2Generates only the resource arg (no update flags).)r$  	r3  r$  r.  r8  r6  r  ru  r   ConceptParser	r!   rU   r/  rO  rQ   rP  r$  r  presentation_specs	            r&   rk  z(YAMLResourceArgument.GenerateResourceArg      
 ">''""5"7
 0""$
 66!7,j: ((	#=? ?r4   c                     t        | j                  || j                  | j                  | j                        }|s|syt        j                  |j                  | j                        }|xr |j                         S 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  rr   r
   r   CONCEPTSrX   )r!   rL   rW   anchor_specifiedresults        r&   rm  z%YAMLResourceArgument.ParseResourceArg  sr    $ *(( N''D224F $flln$r4   c                     | j                   syt        | j                  || j                  | j                  | j
                        S rz  rH   r  r  r  r  rr   rK   s     r&   rM   z(YAMLResourceArgument.IsApiFieldSpecified  s>    ??(( r4   c                 b    | j                  ||       }|rd| j                  z   S | j                  S a  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   rs  r  r!   rg  ro  anchor_arg_is_flags       r&   rp  z,YAMLResourceArgument.GetPresentationFlagName  G     "..^- -  	t%%%;#'#9#9;r4   c                 F    t         j                  j                  | |||      S z6Creates update flags generator using aptiools message.r   UpdateResourceArgumentGeneratorr   r!   rg  ro  rQ   s       r&   r   z)YAMLResourceArgument._GenerateUpdateFlags  *      ??KK!>3HJ Jr4   c                 F    | j                  ||      j                  ||      S r   r   rX   r!   rg  ro  rL   rV   s        r&   r   z2YAMLResourceArgument._ParseUpdateArgsFromNamespace  )     $$^--2U9g-FGr4   c                     | j                  |      }t        |      }| j                  r!| j                  |||      j	                         S | j                  || j                  ||      d|| j                        S )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/  rO  rQ   rP  rx  r  rr   r   rR   rk  rp  rP  r!   rP   rQ   rg  ro  s        r&   rR   zYAMLResourceArgument.Generate#  s     33G<(N~~&&
~/DFFNhjQ %%
!%!=!=!>"3! 5__ & & &r4   c                    | j                   r1| j                  |xr |j                  |j                         ||      }n| j	                  ||      }| j
                   xs | j                  |      }| j                  r|s|syt        j                  |||t        || j                        | j                  | j                  | j                  |xr |j                               y)r   Nr  rF  r,   rD  rr   r   rw  r  rm  rH   rM   r+   r
   ParseResourceIntoMessager  r*   rF  r,   rh  r!   rU   rV   rL   rW   r  user_specifieds          r&   rX   zYAMLResourceArgument.Parse<  s     ~~..

8V88
--/
Wc
 !!)^<c OOBt77	B ++C &&VW,S$2M2MN..00 22:v::<=r4   r5   ry  r   )r6   r7   r8   r9   rY   r~  r'   rZ   rX  r[  r   r]  r`  r  r  r.  r  r6  r  rh  r  rk  rm  rM   rp  r   r   rR   rX   r   r   s   @r&   rK  rK  
  sA   LN N(F, C C     , , 3 3 M M* F F     M M:
+^ 8<
 EI-1?.%@	;* HLJG&2=r4   rK  c                       e Zd ZdZd fd	Zed        Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zed        Zd Z	 ddZ	 	 ddZddZd Zd Z	 ddZd ZddZddZ xZS )rJ  r|  c                     t        t        | 
  ||fi | g | _        |j	                  dg       D ]=  }| j                  j                  t        j                  ||| j                               ? y )NrI  )rC  )	r   rJ  r'   
_resourcesr   appendrK  r~  rC  )r!   r"   rP  rH  rL  resource_datar   s         r&   r'   z&YAMLMultitypeResourceArgument.__init__a  sr    	
'7j$"$ DO+r2
oo

+
+!!%!8!8 , :; 3r4   c                      y r5   r:   rG   s    r&   rX  z(YAMLMultitypeResourceArgument.collectionm      r4   c                 T    | j                   D cg c]  }|j                   c}S c c}w r5   )r  rX  )r!   r)   s     r&   r[  z)YAMLMultitypeResourceArgument.collectionsq  s$    04@HH@@@r   c                      y)NTr:   rG   s    r&   r   z'YAMLMultitypeResourceArgument.multitypeu  r  r4   c                 ,    t        | j                        S r5   r  rG   s    r&   r]  z%YAMLMultitypeResourceArgument.anchorsy  r  r4   c                 ,    t        | j                        S r5   r  rG   s    r&   r`  z-YAMLMultitypeResourceArgument.attribute_names}  r  r4   c                 r    | j                   r| j                   S t        | j                  | j                        S r5   r  rG   s    r&   r  z/YAMLMultitypeResourceArgument.presentation_name  r  r4   c                 z    | j                  dt        j                  | j                        di d      j                  S )rc  FNr  rG   s    r&   r.  z3YAMLMultitypeResourceArgument.attribute_to_flag_map  r  r4   c                     | j                   j                         D ci c]  \  }}|t        j                  |       c}}S c c}}w r5   r  r  s      r&   r  z9YAMLMultitypeResourceArgument._attribute_to_flag_dest_map  r  r  c                 B    t        | j                  | j                        S r  r  rG   s    r&   r6  z+YAMLMultitypeResourceArgument.ignored_flags  r  r4   c                     g }| j                   D ]M  }|j                  s$t        dj                  | j                              |j                  |j                         O t        j                  | j                  g| S )r  zIdisable_auto_completers must be True for multitype resource argument [{}])	r  r  
ValueErrorr0   r   r  r  r   MultitypeResourceSpec)r!   resource_specssub_resources      r&   r  z,YAMLMultitypeResourceArgument._resource_spec  sr     N22 <<BF499<MO 	OL778 ( **499F~FFr4   c                    | j                   s| j                   y| j                  D ]  }|j                  |      s y | j                   rDt        j                  dj                  | j                  |j                  |j                              y)r  FTzCollection names do not align with resource argument specification [{}]. Expected [{} version {}], and no contained resources matched.)	rD  r  rh  r	   r/   r0   r   r  r   )r!   rg  r  s      r&   rh  z/YAMLMultitypeResourceArgument.IsPrimaryResource  s     ##(@(@(L		'	'(;	< ( ##%vii,66!-- /0 0 r4   c           
      r    t        j                  || j                  |d|i ||xs i | j                        S r  )r   !MultitypeResourcePresentationSpecr  r   r  s         r&   r  z7YAMLMultitypeResourceArgument._GeneratePresentationSpec  sG     ??N/N4F4L"N}} r4   c                     t        | j                  | j                  ||      }t        || j                  | j                        }| j                  | j                  |      ||||      }t        j                  |g|      S r  r  r  s	            r&   rk  z1YAMLMultitypeResourceArgument.GenerateResourceArg  r  r4   c                    t        | j                  || j                  | j                  | j                        }|s|syt        j                  |j                  | j                        }|xr |j                         }|xr |j                  S r  )
r  r  r  r  rr   r
   r   r  rX   r  )r!   rL   rW   is_anchor_specifiedr  parsed_results         r&   rm  z.YAMLMultitypeResourceArgument.ParseResourceArg  s    $ -(( ~''D224F -v||~M1]111r4   c                     | j                   syt        | j                  || j                  | j                  | j
                        S rz  r  rK   s     r&   rM   z1YAMLMultitypeResourceArgument.IsApiFieldSpecified  s<    ??Y(($*@*@ r4   c                 b    | j                  ||       }|rd| j                  z   S | j                  S r  r  r  s       r&   rp  z5YAMLMultitypeResourceArgument.GetPresentationFlagName  r  r4   c                 F    t         j                  j                  | |||      S r  r  r  s       r&   r   z2YAMLMultitypeResourceArgument._GenerateUpdateFlags.  r  r4   c                 F    | j                  ||      j                  ||      S r   r  r  s        r&   r   z;YAMLMultitypeResourceArgument._ParseUpdateArgsFromNamespace4  r  r4   c                     | j                  |      }t        |      }| j                  r!| j                  |||      j	                         S | j                  || j                  ||      d || j                        S )Nr  r  r  s        r&   rR   z&YAMLMultitypeResourceArgument.Generate:  s    33G<(N~~&&
~/DFFNhjQ %%
!%!=!=!>"3! 5__ & & &r4   c                    | j                   r1| j                  |xr |j                  |j                         ||      }n| j	                  ||      }| j
                   xs | j                  |      }| j                  r|s|sy t        j                  |||t        || j                        | j                  | j                  | j                  |xr |j                               y )Nr  r  r  s          r&   rX   z#YAMLMultitypeResourceArgument.ParseJ  s    ~~..

8V88
--/
Wc
 !!)^<c OOBt77	B ++C &&VW,S$2M2MN..00 22:v::<=r4   r5   ry  r   )r6   r7   r8   r9   r'   rZ   rX  r[  r   r]  r`  r  r.  r  r6  r  rh  r  rk  rm  rM   rp  r   r   rR   rX   r   r   s   @r&   rJ  rJ  ^  s'   L
;   A A   , , 3 3 F F     M M G G@ 8<
 EI-1?.2B;* HLJG& =r4   rJ  )F)1r9   
__future__r   r   r   r[   ro   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr   r   r	   r`   $googlecloudsdk.command_lib.util.apisr
   r   r   r   r   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.core.utilr   objectr   r    ABCMetar   rw   rB   rD   r   r   r   r   r  r
  r  r  r!  r(  r3  r8  r@  rC   rK  rJ  r:   r4   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=r4   