
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SS	Kr  SS
 jr    SS jrg	)z%Module for resource_args API support.    )absolute_import)division)unicode_literals)concepts)	yaml_data)concept_parsers)presentation_specsNc                 (   [         R                  R                  U5      n[        R                  R                  UR                  5       5      n[        R                  R                  U(       a  UOUR                  5       UUUS9R                  U 5        g)a  Adds a resource argument in a python command.

Args:
  parser: the parser for the command.
  resource_path: string, the resource_path which refers to the resources.yaml.
  help_text: string, the help text of the resource argument.
  name: string, the default is the name specified in the resources.yaml file.
  required: boolean, the default is True because in most cases resource arg is
    required.
)nameresource_spec
group_helprequiredN)r   ResourceYAMLDataFromPathr   ResourceSpecFromYamlGetDatar   ConceptParserForResource
GetArgNameAddToParser)parserresource_path	help_textr   r   resource_yaml_datar   s          9lib/googlecloudsdk/command_lib/util/args/resource_args.pyAddResourceArgToParserr      sz     !11::=I''001C1K1K1MN-++D0;;=!	 ,  %V,    c                 (   U(       a  U OSU -   nUR                  XS9n	U(       a:  [        R                  " U5       H   u  pUS    H  nUS   U
:X  d  M  XS'   M     M"     [        R                  " U[
        R                  R                  U5      U	UUS9$ )a  Build ResourcePresentationSpec for a Resource.

Args:
  name: string, name of resource anchor argument.
  verb: string, the verb to describe the resource, such as 'to create'.
  resource_data: dict, the parsed data from a resources.yaml file under
      command_lib/.
  attribute_overrides: dict{string:string}, map of resource attribute names to
    override in the generated resrouce spec.
  help_text: string, the help text for the entire resource arg group. Should
    have 2 format format specifiers (`{name}`, `{verb}`) to insert the
    name and verb repectively.
  required: bool, whether or not this resource arg is required.
  prefixes: bool, if True the resource name will be used as a prefix for
    the flags in the resource group.
  positional: bool, if True, means that the resource arg is a positional
    rather than a flag.
Returns:
  ResourcePresentationSpec, presentation spec for resource.
z--)verbr   
attributesattribute_name)r   prefixes)formatsix	iteritemsr	   ResourcePresentationSpecr   r   r   )r   r    resource_dataattribute_overridesr   r   r#   
positionalarg_namearg_helpr"   valueattrs                r   GetResourcePresentationSpecr/   6   s    2  TTD[(43(!$/B!C-$ !^3#(
  . "D
 
	4	4$$]3
 r   )NT)NzThe {name} {verb}.FTF)__doc__
__future__r   r   r    googlecloudsdk.calliope.conceptsr   $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   r	   r%   r   r/    r   r   <module>r6      sD    , &  ' 5 : D G  !%$(	-2 59*>9=+0	(r   