
    $                         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 rS	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rg)z#parsing flags for Recommender APIs.    )absolute_import)division)unicode_literals)base)arg_parsers)common_argsc                     U R                  SSS9n[        R                  " SS9R                  U5        UR	                  SSSS	9  UR	                  S
SSS	9  UR	                  SSSS	9  g)zAdding argument mutex group project, billing-account, folder, organization to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
TzResource that is associated with cloud entity type. Currently four mutually exclusive flags are supported, --project, --billing-account, --folder, --organization.requiredhelpz%The Google Cloud Platform project ID.help_text_to_overwrite--billing-accountBILLING_ACCOUNTzHThe Google Cloud Platform billing account ID to use for this invocation.metavarr   --organizationORGANIZATION_IDzEThe Google Cloud Platform organization ID to use for this invocation.--folder	FOLDER_IDz?The Google Cloud Platform folder ID to use for this invocation.N)add_mutually_exclusive_groupr   ProjectArgumentAddToParseradd_argument)parserresource_groups     3lib/googlecloudsdk/command_lib/recommender/flags.pyAddParentFlagsToParserr      s     66 p 7 . DKU  
 R  
 L  N    c                    U R                  SSS9n[        R                  R                  U;   a  UR	                  SSSS9  [        R                  R
                  U;   a  UR	                  SS	S
S9  [        R                  R                  U;   a  UR	                  SSSS9  [        R                  R                  U;   a$  [        R                  " SS9R                  U5        gg)zAdds argument mutex group of specified entities to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
    entities: The entities to add.
Tz3Resource that is associated with cloud entity type.r
   r   r   z<The Google Cloud organization ID to use for this invocation.r   r   r   z6The Google Cloud folder ID to use for this invocation.r   r   z?The Google Cloud billing account ID to use for this invocation.zThe Google Cloud project ID.r   N)r   r   
EntityTypeORGANIZATIONr   FOLDERr   PROJECTr   r   r   )r   entitiesr   s      r   AddEntityFlagsToParserr&   8   s     66O 7 Q.	__!!X-!K   M 
__x'E   G 
__$$0!N   P 
__(=??J{@ )r   c                 `    [        X5        U R                  SSSSS9  U R                  SSSS	9  g
)zAdds argument mutex group of specified entities and insight type to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
    entities: The entities to add.

--locationLOCATIONT$Location to use for this invocation.r   r   r   insight_typeINSIGHT_TYPEz(Insight type to use for this invocation.r   Nr&   r   r   r%   s     r   AddInsightTypeFlagsToParserr0   W   sI     *1	  3
 	5  7r   c                 `    [        X5        U R                  SSSSS9  U R                  SSSS	9  g
)zAdds argument mutex group of specified entities and recommender to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
    entities: The entities to add.
r(   r)   Tr*   r+   recommenderRECOMMENDERz'Recommender to use for this invocation.r   Nr.   r/   s     r   AddRecommenderFlagsToParserr4   k   sI     *1	  3
 	4  6r   c                 B    U R                  SSR                  U5      S9  g)zAdds config file to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
    resource: The resource to add to.
z--config-filez)Generation configuration file for the {}.r   Nr   formatr   resources     r   AddConfigFileToParserr;      s)     	6==hG  Ir   c                 B    U R                  SSR                  U5      S9  g)zAdds display-name to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
    resource: The resource to add to.
z--display-namezDisplay name of the {}.r6   Nr7   r9   s     r   AddDisplayNameToParserr=      s)     	6==hG  Ir   c                 (    U R                  SSSSS9  g)zAdds validate-only to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
z--validate-only
store_trueFzTIf true, validate the request and preview the change, but do not actually update it.)actiondefaultr   N)r   )r   s    r   AddValidateOnlyToParserrB      s#     	a	  r   c                 D    U R                  SSSR                  U5      S9  g)zAdds etag to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
    resource: The resource to add to.
z--etagTzEtag of the {}.r
   Nr7   r9   s     r   AddEtagToParserrD      s+     	$5$<$<X$F  Hr   c           	          U R                  S[        R                  " SS90 SR                  U5      S[        R                  S9  g)zAdds annotations to parser.

Args:
    parser: An argparse parser that you can use to add arguments that go on
      the command line after this command.
    resource: The resource to add to.
z--annotations   )
min_lengthz0Store small amounts of arbitrary data on the {}.z	KEY=VALUE)typerA   r   r   r@   N)r   r   ArgDictr8   StoreOnceActionr9   s     r   AddAnnotationsToParserrK      sD     	!,=vh((  *r   c                 F   [        U S5      (       a   U R                  (       a  SU R                  -  $ [        U S5      (       a   U R                  (       a  SU R                  -  $ [        U S5      (       a   U R                  (       a  SU R                  -  $ SU R                  -  $ )z1Returns the resource from up to the cloud entity.projectzprojects/%sfolderz
folders/%sbilling_accountzbillingAccounts/%szorganizations/%s)hasattrrM   rN   rO   organizationargss    r   GetResourceSegmentrT      s~    T9$,,4<<''tX4;;$++%%t&''D,@,@$"6"666 1 111r   c                 N    [        U 5      nSR                  XR                  5      $ )z-Returns the resource name up to the location.z{}/locations/{})rT   r8   locationrS   parents     r   GetLocationSegmentrY      s!    d#&		!	!&--	88r   c                 N    [        U 5      nSR                  XR                  5      $ z1Returns the resource name up to the insight type.z{}/insightTypes/{})rY   r8   r,   rW   s     r   GetInsightTypeNamer\      s#    d#&		$	$V->->	??r   c                 :    [        U 5      nSR                  X!5      $ r[   )rY   r8   )rS   r,   rX   s      r   GetFullInsightTypeNamer^      s    d#&		$	$V	::r   c                     [        U 5      S-   $ )z6Returns the resource name for the insight type config./config)r\   rR   s    r   GetInsightTypeConfigNamera          	D	!I	--r   c                 P    [        U 5      SR                  U R                  5      -   $ )*Returns the resource name for the insight.z/insights/{0})r\   r8   INSIGHTrR   s    r   GetInsightNamerf      s!    	D	!O$:$:4<<$H	HHr   c                 N    [        U 5      nSR                  XR                  5      $ z0Returns the resource name up to the recommender.z{}/recommenders/{})rY   r8   r2   rW   s     r   GetRecommenderNameri      s#    d#&		$	$V-=-=	>>r   c                 8    SR                  [        U 5      U5      $ rh   )r8   rY   )rS   r2   s     r   GetFullRecommenderNamerk      s    		$	$%7%={	KKr   c                     [        U 5      S-   $ )z5Returns the resource name for the recommender config.r`   )ri   rR   s    r   GetRecommenderConfigNamerm      rb   r   c                 P    [        U 5      SR                  U R                  5      -   $ )rd   z/recommendations/{0})ri   r8   RECOMMENDATIONrR   s    r   GetRecommendationNamerp      s+    	D	!$:$A$A
% 
 r   c                    SR                  U R                  5      nUSR                  U R                  5      -   nU(       a#  USR                  U R                  5      -   nUS-   $ USR                  U R                  5      -   nUS-   $ )a  Parsing args for url string for recommender and insigh type configs apis.

Args:
    args: argparse.Namespace, The arguments that this command was invoked
      with.
    is_insight_api: whether this is an insight api.

Returns:
    The full url string based on flags given by user.
zprojects/{0}z/locations/{0}z/insightTypes/{0}z/recommenders/{0}r`   )r8   rM   rV   r,   r2   )rS   is_insight_apiurls      r   GetConfigsParentFromFlagsrt     s     	dll+#%%dmm44#
#**4+<+<=
=C 
y #**4+;+;<
<C	yr   N)__doc__
__future__r   r   r   "googlecloudsdk.api_lib.recommenderr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.util.argsr   r   r&   r0   r4   r;   r=   rB   rD   rK   rT   rY   r\   r^   ra   rf   ri   rk   rm   rp   rt    r   r   <module>r{      s    * &  ' 3 / <N<>7(6(
I	I	H*$	29@;.
I
?L
.
r   