
    L$                     8   S r SSKJr  SSKJr  SSKJ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rSr " S S\R&                  5      rS"S jrS#S jrS rS"S jrS#S jrS rS rS rS rS rS rS$S jr S r!S$S jr"S r#S  r$S! r%g)%z6Shared resource flags for Transfer Appliance commands.    )absolute_import)division)unicode_literalsN)concepts)deps)regions)concept_parsers)presentation_specs)
properties)	resourcesz/transferappliance.projects.locations.appliancesz+transferappliance.projects.locations.ordersc                   $    \ rS rSrSrSrSrSrSrg)ResourceVerb%   deletedescribelistupdate N)	__name__
__module____qualname____firstlineno__DELETEDESCRIBELISTUPDATE__static_attributes__r       Clib/googlecloudsdk/command_lib/transfer/appliances/resource_args.pyr   r   %   s    &(	$&r   r   c                 4    [         R                  " U SSS0SS9$ )Nz-The appliance affiliated with the {resource}.	fieldMasknamer"   	help_textcompletion_request_paramscompletion_id_fieldr    ResourceParameterAttributeConfigr"   s    r   appliance_attribute_configr*   ,   s&    		2	2?!,f 5 	
" "r   c                 4    [         R                  " U SSS0SS9$ )Nz)The order affiliated with the {resource}.r!   r"   r#   r'   r)   s    r   order_attribute_configr,   4   s&    		2	2;!,f 5 	
" "r   c                  X    [         R                  " SS[        R                  " S5      /S9$ )Nregionz*The region affiliated with the {resource}.--region)r"   r$   fallthroughs)r   r(   r   ArgFallthroughr   r   r   region_attribute_configr2   <   s,    		2	2<''
34
6 6r   c           	      v    [         R                  " [        U [        U S9[	        5       [         R
                  SS9$ )Nr)   F)resource_nameappliancesIdlocationsId
projectsIddisable_auto_completers)r   ResourceSpecAPPLIANCES_COLLECTIONr*   r2    DEFAULT_PROJECT_ATTRIBUTE_CONFIGr4   s    r   get_appliance_resource_specr=   C   s5    			!-=A)+::#
% %r   c           	      v    [         R                  " [        U [        U S9[	        5       [         R
                  SS9$ )Nr)   F)r4   ordersIdr6   r7   r8   )r   r9   ORDERS_COLLECTIONr,   r2   r;   r<   s    r   get_order_resource_specrA   M   s5    			!%=9)+::#
% %r   c                     U R                  S[        R                  [        R                  SR                  UR                  5      S9  g)aI  Add region flag for appliances/orders.

Normally we'd rely on the argument output by region_attribute_config() but
we can set "choices" and convert the value to lower if we add it this way.

Args:
  parser (arg_parse.Parser): The parser for the command.
  verb (ResourceVerb): The action taken on the resource, such as 'update'.
r/   z7The location affiliated with the appliance order to {}.)choicestypehelpN)add_argumentr   CLOUD_REGIONSstrlowerformatvalueparserverbs     r   _add_region_flagrO   W   s?     	##99DKK
**	  r   c           	          [         R                  R                  S[        5       SR	                  UR
                  5      SS0SSS9R                  U 5        [        X5        g)a  Add a resource argument for a transfer appliance.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser (arg_parse.Parser): The parser for the command.
  verb (ResourceVerb): The action taken on the resource, such as 'update'.
	appliancezThe appliance to {}.r.    Tflag_name_overridesprefixesrequiredN)r	   ConceptParserForResourcer=   rJ   rK   AddToParserrO   rL   s     r   add_appliance_resource_argrZ   i   sY     ++!###DJJ/#R. ,  ![(6 r   c           	          [         R                  R                  S[        5       SR	                  UR
                  5      SS0SSS9R                  U 5        [        X5        g)a
  Add a resource argument for a transfer appliance order.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser (arg_parse.Parser): The parser for the command.
  verb (ResourceVerb): The action taken on the resource, such as 'update'.
orderzThe order to {}.r.   rR   TrS   N)r	   rW   rX   rA   rJ   rK   rY   rO   rL   s     r   add_order_resource_argr]   |   sY     ++

+#R. ,  ![(6 r   c                 t    [         R                  R                  S[        5       SSSS9R	                  U 5        g)zAdd a resource argument for cloning a transfer appliance.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser (arg_parse.Parser): The parser for the command.
z--clonezThe order to clone.TF)rU   rV   N)r	   rW   rX   rA   rY   )rM   s    r   add_clone_resource_argr_      s;     ++ , 
 "k&)r   c                     [         R                  R                  U R                  S[        R
                  R                  R                  R                  5       0[        S9R                  5       $ Nr7   )params
collection)r   REGISTRYParser"   r   VALUEScoreprojectGetr:   SelfLinkrQ   s    r   _get_appliance_urirl      sV    				!	!nnJ--22::>>@A& 
" 
( )1
3r   c                     [         R                  R                  U R                  S[        R
                  R                  R                  R                  5       0[        S9R                  5       $ ra   )r   rd   re   r"   r   rf   rg   rh   ri   r@   rj   r\   s    r   _get_order_uriro      sV    				!	!jjJ--22::>>@A" 
" 
$ %-HJ/r   c           
         [         R                  nSnSnU(       aY  UR                  SUR                  5      nUR                  SSUR                  5      nU R                  R                  [        5        OXUR                  SUR                  5      nUR                  SSUR                  5      nU R                  R                  [        5        [        R                  " S[        S5      USS0SS	S
9[        R                  " S[        S5      USS0SSS
9/n[        R                  " U5      R                  U 5        [        X5        g)a  Add both order and appliance resource arguments for list commands.

Args:
  parser (arg_parse.Parser): The parser for the command.
  listing_orders (bool): Toggles the help text phrasing to match either orders
    or appliances being the resource being listed.
zThe {} to {}.z$The {} associated with the {} to {}.orders
appliancesz--appliancesr.   rR   TF)rT   pluralrU   z--ordersN)r   r   rJ   rK   display_info
AddUriFuncro   rl   r
   ResourcePresentationSpecr=   rA   r	   rW   rY   rO   )rM   listing_ordersrN   primary_helpsecondary_helporders_helpappliances_help	arg_specss           r   add_list_resource_argsr}      s!    
		$ ,9.%%h

;K$++L(DJJOO
"">2")),

CO '',

KK
""#56 11

%l
3
'n 11

!(
+
'n)" 	*66v>6 r   c                     U(       d  gU Vs/ s H"  nSR                  XR                  5       5      PM$     nnSR                  U5      nSR                  U5      $ s  snf )NrR   z{}:{}z OR z({}))rJ   RelativeNamejoin)
filter_keyresource_refsreffilter_listresource_lists        r   !_get_filter_clause_from_resourcesr      sZ    	@M@MgnnZ!1!1!34   ++k*-	}	%%	s   )Ac                    U R                   (       a  U R                   /O/ nU R                  S5      (       aP  U R                  R                  R	                  5       nU(       a%  U(       a  SOSnUR                  [        XC5      5        U R                  S5      (       aP  U R                  R                  R	                  5       nU(       a%  U(       a  SOSnUR                  [        XE5      5        SR                  U5      $ )a'  Parses list resource args as a filter string.

Args:
  args (parser_extensions.Namespace): the parsed arguments for the command.
  listing_orders (bool): Toggles the appropriate keys for order and appliance
    depending on which resource is primarily being listed.

Returns:
  A filter string.
rq   r"   r\   rr   z AND )	filterIsSpecifiedCONCEPTSrq   re   appendr   rr   r   )argsrw   r   
order_refsr   appliance_refss         r   )parse_list_resource_args_as_filter_stringr      s     "&"+	h%%++-J+6j:
" #	l##]]--335N#1<vj:
& '	k	""r   c                     [         R                  R                  R                  R	                  5       nSR                  X=(       d    S5      $ )zHReturns a presentation string for list and create calls, given a region.zprojects/{}/locations/{}-)r   rf   rg   rh   ri   rJ   )r.   rh   s     r   get_parent_stringr      s7    ""**..0'	#	*	*7Mc	BBr   c           	          [         R                  R                  [         R                  R	                  [
        UU [        R                  R                  R                  R                  5       S95      $ )z9Returns an appliance name to locations and appliances ID.)r5   r6   r7   )r   Resourcer   rd   Creater:   r   rf   rg   rh   ri   )locations_idappliances_ids     r   get_appliance_namer     s[    				(	(
$"&&++33779	   ;
< <r   c           	          [         R                  R                  [         R                  R	                  [
        UU [        R                  R                  R                  R                  5       S95      $ )z5Returns an appliance name to locations and orders ID.)r?   r6   r7   )r   r   r   rd   r   r@   r   rf   rg   rh   ri   )r   	orders_ids     r   get_order_namer     s[    				(	(
"&&++33779	   ;
< <r   rk   rn   )T)&__doc__
__future__r   r   r   enum googlecloudsdk.calliope.conceptsr   r   .googlecloudsdk.command_lib.transfer.appliancesr   (googlecloudsdk.command_lib.util.conceptsr	   r
   googlecloudsdk.corer   r   r:   r@   Enumr   r*   r,   r2   r=   rA   rO   rZ   r]   r_   rl   ro   r}   r   r   r   r   r   r   r   r   <module>r      s     = &  '  5 1 B D G * ) J A 499 ""6%%$!&!&* 3/&!R&#6C<<r   