
                            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rSSKrSSKJ	r	  SSK
Jr  SS	KJr  \R                  " S
S5      r\" SSSSS5      \" SSSSS5      \" SSSSS5      \" SSSSS5      \" SSSSS5      \" SSSSS 5      \" S!S"S!SS#5      \" S$S%S&S'S(5      \" S)S*S)SS+5      \" S,S-S.SS/5      \" S0S1S2SS35      /r\ V s0 s H  o R"                  U _M     sn rS4 rS5 rS;S7 jr\" 5       SS64S8 jr\" 5       S9SSS6S6S4S: jrgs  sn f )<z@Specifications for resource-identifying command line parameters.    )absolute_import)division)print_function)unicode_literalsN)arg_parsers)concepts)concept_parsersEntityNamesz=singular plural docs_name valid_pattern secondary_descriptionprojectprojectsz&GCP project containing the {resource}.organizationorganizationsz^[a-z][-a-z0-9]{0,30}[a-z0-9]$zApigee organization containing the {resource}. If unspecified, the Cloud Platform project's associated organization will be used.apiapisz	API proxyz^[\s\w.-]{1,255}$zAPI proxy for the {resource}.environmentenvironmentsz)Deployment environment of the {resource}.revision	revisionszRevision of the {resource}.
deploymentdeploymentsz&Relevant deployment of the {resource}.	operation
operationsz&Operation operating on the {resource}.productapiproductszAPI productz^[A-Za-z0-9._$ %-]+$z$Relevant product for the {resource}.	developer
developerszDeveloper of the {resource}.appappsapplicationz(Relevant application for the {resource}.archive_deploymentarchiveDeploymentszarchive deploymentz!Archive deployment for {resource}c                 6    [         U    R                  nUc  S$ U$ )Nz.*)ENTITIESvalid_pattern)namepatterns     6lib/googlecloudsdk/command_lib/apigee/resource_args.py_ValidPatternForEntityr(   G   s     TN(('/.w.    c                 @    [         R                  " [        U 5      5      $ )zEReturns a compiled regex that matches valid values for `entity_name`.)recompiler(   )entity_names    r'   ValidPatternForEntityr.   L   s    	*;7	88r)   Fc                    SnU(       a4  [         R                  " [        U 5      SR                  " [        U    6 5      n[
        R                  " U [        U    R                  UU=(       d    [        U    R                  US9$ )a  Returns a ResourceParameterAttributeConfig for the attribute named `name`.

Args:
  name: singular name of the attribute. Must exist in ENTITIES.
  fallthroughs: optional list of gcloud fallthrough objects which should be
    used to get this attribute's value if the user doesn't specify one.
  help_text: help text to use for this resource parameter instead of the
    default help text for the attribute.
  validate: whether to check that user-provided value for this attribute
    matches the expected pattern.
Nz*Must match the format of a valid {2} ({3}))r%   parameter_name
value_type	help_textfallthroughs)	r   RegexpValidatorr(   formatr#   r    ResourceParameterAttributeConfigpluralsecondary_description)r%   r3   r2   validate	validators        r'   AttributeConfigr;   Q   st     )++t$4;;Xd^LNI 
	2	2d^**AXd^AA
! !r)   c                    [         R                  " S U=(       d    0 5      nU  Vs/ s H  n[        U   PM     nn0 nU HZ  nU Vs/ s H  nUR                  U;   d  M  UPM     n	n[	        UR                  U	X'R                     US9n
XUR
                  S-   '   M\     [        R                  " SSR                  S U 5       5      -   4SUS   R                  0UD6$ s  snf s  snf )	a  Returns a ResourceSpec for the resource path `path`.

Args:
  path: a list of attribute names. All must exist in ENTITIES.
  fallthroughs: optional list of googlecloudsdk.command_lib.apigee.Fallthrough
    objects which will provide default values for the attributes in `path`.
  help_texts: a mapping of attribute names to help text strings, to use
    instead of their default help text.
  validate: whether to check that the user-provided resource matches the
    expected naming conventions of the resource path.
c                      g N r?   r)   r'   <lambda>ResourceSpec.<locals>.<lambda>w   s    tr)   r9   Idzapigee..c              3   8   #    U  H  oR                   v   M     g 7fr>   )r7   ).0entitys     r'   	<genexpr>ResourceSpec.<locals>.<genexpr>   s     @xV==xs   resource_name)
collectionsdefaultdictr#   singularr;   r7   r   ResourceSpecjoin	docs_name)pathr3   
help_textsr9   r%   entitiesidsrG   fallthroughrelevant_fallthroughsconfigs              r'   rO   rO   k   s     &&|Z5E2F*)-.htn(.
#f'3'3??k) 	|   ??#	F
 !'  
		#((@x@@@
RL**
 	
  /s   CC!C!Tc
           
      
   UR                  S5      n
Uc2  U
S   nU(       a  UR                  5       nOSUR                  SS5      -   nUc  Un[        R                  R                  U[        XXS9UUUS9R                  U 5        g)	a  Creates a concept parser for `resource_path` and adds it to `parser`.

Args:
  parser: the argparse.ArgumentParser to which the concept parser will be
    added.
  resource_path: path to the resource, in `entity.other_entity.leaf` format.
  help_text: the help text to display when describing the resource as a whole.
  fallthroughs: fallthrough providers for entities in resource_path.
  positional: whether the leaf entity should be provided as a positional
    argument, rather than as a flag.
  argument_name: what to name the leaf entity argument. Defaults to the leaf
    entity name from the resource path.
  required: whether the user is required to provide this resource. Defaults to
    True for positional arguments, False otherwise.
  prefixes: whether to append prefixes to the non-leaf arguments.
  validate: whether to check that the user-provided resource matches the
    expected naming conventions of the resource path.
  help_texts: custom help text for generated arguments. Defaults to each
    entity using a generic help text.
rD   NrK   z--_-rB   )requiredprefixes)splitupperreplacer	   ConceptParserForResourcerO   AddToParser)parserresource_pathr2   r3   
positionalargument_namer\   r]   r9   rS   
split_pathleaf_element_names               r'   AddSingleResourceArgumentrj      s    < ""3'*"2'--/m.66sC@@mH++:ZK , 
 %V,r)   )NNF)__doc__
__future__r   r   r   r   rL   r+   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr   (googlecloudsdk.command_lib.util.conceptsr	   
namedtuple_EntityNames_ENTITY_TUPLESrN   r#   r(   r.   r;   tuplerO   rj   )items   0r'   <module>ru      s   G &  % '  	 / 5 D %%CE
 J
D9;)	%& -A022<> [*d.0}lD9;lK9;M=(79 lK/1t;=%';%t467> -;;NDMM4N;/
9
!4 %*Gu H ,17)-,0'+',',)-.-Q <s   D
