
                             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Jr  SS
KJr  SS jrSS jrS S jrS S jrS S 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#g)!z'Utilities for networkservices commands.    )absolute_import)division)unicode_literals)
list_pager)network_services)apis)concepts)	multitype)	yaml_datac                 B   ^ [         R                  " SU 5      mU4S jnU$ )a  Hook to transform AutoCapacityDrain flag to actual message.

This function is called during ServiceLbPolicy create/update command to
create the AutoCapacityDrain message. It returns a function which is called
with arguments passed in the gcloud command.

Args:
  api_version: Version of the networkservices api

Returns:
   Function to transform boolean flag to AutcapacityDrain message.
networkservicesc                 2   > U (       a  TR                  U S9$ g )N)enable) ServiceLbPolicyAutoCapacityDrain)r   messagess    7lib/googlecloudsdk/command_lib/network_services/util.pyConstructAutoCapacityDrain9AutoCapacityDrainHook.<locals>.ConstructAutoCapacityDrain,   s    66f6EE     r   GetMessagesModule)api_versionr   r   s     @r   AutoCapacityDrainHookr      s&     ##$5{C(F 
$#r   c                 B   ^ [         R                  " SU 5      mU4S jnU$ )a  Hook to transform FailoverHealthThreshold flag to actual message.

This function is called during ServiceLbPolicy create/update command to
create the FailoverConfig message. It returns a function which is called
with arguments passed in the gcloud command.

Args:
  api_version: Version of the networkservices api

Returns:
   Function to transform integer flag to FailoverConfig message.
r   c                 "   > TR                  U S9$ )N)failoverHealthThreshold)ServiceLbPolicyFailoverConfig)	thresholdr   s    r   ConstructFailoverConfig<FailoverHealthThresholdHook.<locals>.ConstructFailoverConfigB   s    11 ) 2  r   r   )r   r   r   s     @r   FailoverHealthThresholdHookr!   3   s%     ##$5{C(
 
! r   Nc                 f    SU;   a  [        XX#5      $ SU;   a  [        XX#5      $ [        SU-  5      e)z0Calls appropriate List method based on the name.meshesgatewaysInvalid name: %s)_ListMeshRouteViews_ListGatewayRouteViews
ValueError)trackname	page_sizelimits       r   ListRouteViewsr-   J   s=    uI==T!%y@@
'$.
//r   c           	          [         R                  " U 5      n[         R                  " U 5      nUR                  US9n[        R
                  " UR                  USUUSS9$ )zCalls ListMeshRouteViews API.parentmeshRouteViewspageSizeservicerequestfield
batch_sizer,   batch_size_attribute)ns_apiGetClientInstancer   ;NetworkservicesProjectsLocationsMeshesRouteViewsListRequestr   YieldFromList$projects_locations_meshes_routeViewsr)   r*   r+   r,   clientmsgr5   s          r   r&   r&   T   sh    ##E*&  '#KK L ' 
	!	!99%
 r   c           	          [         R                  " U 5      n[         R                  " U 5      nUR                  US9n[        R
                  " UR                  USUUSS9$ )z Calls ListGatewayRouteViews API.r/   gatewayRouteViewsr2   r3   )r9   r:   r   =NetworkservicesProjectsLocationsGatewaysRouteViewsListRequestr   r<   &projects_locations_gateways_routeViewsr>   s          r   r'   r'   e   sh    ##E*&  '#MM N '
 
	!	!;;%
 r   c                 b    SU;   a  [        X5      $ SU;   a  [        X5      $ [        SU-  5      e)z/Calls appropriate Get method based on the name.r#   r$   r%   )_GetMeshRouteView_GetGatewayRouteViewr(   )r)   r*   s     r   GetRouteViewrH   x   s9    U))T,,
'$.
//r   c                     [         R                  " U 5      n[         R                  " U 5      nUR                  US9nUR                  R                  U5      $ Nr*   )r9   r:   r   :NetworkservicesProjectsLocationsMeshesRouteViewsGetRequestr=   Getr)   r*   r?   r@   r5   s        r   rF   rF      sT    ##E*&  '#JJ K ' 
	4	4	8	8	AAr   c                     [         R                  " U 5      n[         R                  " U 5      nUR                  US9nUR                  R                  U5      $ rJ   )r9   r:   r   <NetworkservicesProjectsLocationsGatewaysRouteViewsGetRequestrD   rM   rN   s        r   rG   rG      sT    ##E*&  '#LL M ' 
	6	6	:	:7	CCr   c                      [         R                  R                  S5      n [        R                  R                  U R                  5       5      $ )z>Reads the gateway route view resource spec from the yaml file.znetwork_services.locationr   ResourceYAMLDataFromPathr	   ResourceSpecFromYamlGetDatadatas    r   LocationResourceSpecrZ      s6    		#	#	,	,-H	I$				'	'	77r   c                      [         R                  R                  S5      n [        R                  R                  U R                  5       5      $ )z0Reads the mesh resource spec from the yaml file.znetwork_services.meshrR   rX   s    r   MeshResourceSpecr\      s6    		#	#	,	,-D	E$				'	'	77r   c                      [         R                  R                  S5      n [        R                  R                  U R                  5       5      $ )z3Reads the gateway resource spec from the yaml file.znetwork_services.gatewayrR   rX   s    r   GatewayResourceSpecr^      s6    		#	#	,	,-G	H$				'	'	77r   c                 T    SU ;   =(       a    SU ;   =(       a    SU ;   =(       d    SU ;   $ )z/Returns whether name is a fully qualified name.z	projects/	locationsr#   r$    rK   s    r   IsFullyQualifiedNamerb      s5     T 3

3t1zT1r   c                  ,    [         R                  " SSS9$ )NlocationzLocation of the {resource}r*   	help_textr	    ResourceParameterAttributeConfigra   r   r   LocationAttributeConfigri      s    		2	2,
 r   c                  ,    [         R                  " SSS9$ )NmeshzParent Mesh of the {resource}re   rg   ra   r   r   MeshAttributeConfigrl      s    		2	2/
 r   c                  ,    [         R                  " SSS9$ )Ngatewayz Parent Gateway of the {resource}re   rg   ra   r   r   GatewayAttributeConfigro      s    		2	22
 r   c                  ,    [         R                  " SSS9$ )N
route-viewzThe RouteView resourcere   rg   ra   r   r   RouteViewAttributeConfigrr      s    		2	2(
 r   c            
          [         R                  " SS[         R                  [        5       [	        5       [        5       SS9$ )Nz4networkservices.projects.locations.meshes.routeViewsrq   T)resource_name
projectsIdlocationsIdmeshesIdrouteViewsIdis_positional)r	   rU    DEFAULT_PROJECT_ATTRIBUTE_CONFIGri   rl   rr   ra   r   r   MeshRouteViewResourceSpecr{      s9    			< ::)+"$+-
 r   c            
          [         R                  " SS[         R                  [        5       [	        5       [        5       SS9$ )Nz6networkservices.projects.locations.gateways.routeViewsrq   T)rt   ru   rv   
gatewaysIdrx   ry   )r	   rU   rz   ri   ro   rr   ra   r   r   GatewayRouteViewResourceSpecr~      s9    			> ::)+')+-
 r   c                  P    [         R                  " S[        5       [        5       SS9$ )Nmesh_or_gateway_route_viewT)allow_inactive)r
   MultitypeResourceSpecr{   r~   ra   r   r   "MeshOrGatewayRouteViewResourceSpecr      s'    		(	("!"$	
 r   )v1)d   N)$__doc__
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_libr   r9   googlecloudsdk.api_lib.utilr    googlecloudsdk.calliope.conceptsr	   r
   $googlecloudsdk.command_lib.util.apisr   r   r!   r-   r&   r'   rH   rF   rG   rZ   r\   r^   rb   ri   rl   ro   rr   r{   r~   r   ra   r   r   <module>r      s    . &  ' ' = , 5 6 :$,!.0"&0BD888		r   