
    >                         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 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.    )
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>.ConstructFailoverConfig?   s    11 ) 2  r   r   )r   r   r   s     @r   FailoverHealthThresholdHookr   0   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*   G   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msgr2   s          r   r#   r#   Q   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,   gatewayRouteViewsr/   r0   )r6   r7   r   =NetworkservicesProjectsLocationsGatewaysRouteViewsListRequestr   r9   &projects_locations_gateways_routeViewsr;   s          r   r$   r$   b   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   GetRouteViewrE   u   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'   )r6   r7   r   :NetworkservicesProjectsLocationsMeshesRouteViewsGetRequestr:   Getr&   r'   r<   r=   r2   s        r   rC   rC      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      $ rG   )r6   r7   r   <NetworkservicesProjectsLocationsGatewaysRouteViewsGetRequestrA   rJ   rK   s        r   rD   rD      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   LocationResourceSpecrW      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.meshrO   rU   s    r   MeshResourceSpecrY      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.gatewayrO   rU   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!    rH   s    r   IsFullyQualifiedNamer_      s5     T 3

3t1zT1r   c                  ,    [         R                  " SSS9$ )NlocationzLocation of the {resource}r'   	help_textr    ResourceParameterAttributeConfigr^   r   r   LocationAttributeConfigrf      s    		2	2,
 r   c                  ,    [         R                  " SSS9$ )NmeshzParent Mesh of the {resource}rb   rd   r^   r   r   MeshAttributeConfigri      s    		2	2/
 r   c                  ,    [         R                  " SSS9$ )Ngatewayz Parent Gateway of the {resource}rb   rd   r^   r   r   GatewayAttributeConfigrl      s    		2	22
 r   c                  ,    [         R                  " SSS9$ )N
route-viewzThe RouteView resourcerb   rd   r^   r   r   RouteViewAttributeConfigro      s    		2	2(
 r   c            
          [         R                  " SS[         R                  [        5       [	        5       [        5       SS9$ )Nz4networkservices.projects.locations.meshes.routeViewsrn   T)resource_name
projectsIdlocationsIdmeshesIdrouteViewsIdis_positional)r   rR    DEFAULT_PROJECT_ATTRIBUTE_CONFIGrf   ri   ro   r^   r   r   MeshRouteViewResourceSpecrx      s9    			< ::)+"$+-
 r   c            
          [         R                  " SS[         R                  [        5       [	        5       [        5       SS9$ )Nz6networkservices.projects.locations.gateways.routeViewsrn   T)rq   rr   rs   
gatewaysIdru   rv   )r   rR   rw   rf   rl   ro   r^   r   r   GatewayRouteViewResourceSpecr{      s9    			> ::)+')+-
 r   c                  P    [         R                  " S[        5       [        5       SS9$ )Nmesh_or_gateway_route_viewT)allow_inactive)r   MultitypeResourceSpecrx   r{   r^   r   r   "MeshOrGatewayRouteViewResourceSpecr      s'    		(	("!"$	
 r   )v1)d   N) __doc__apitools.base.pyr   googlecloudsdk.api_libr   r6   googlecloudsdk.api_lib.utilr    googlecloudsdk.calliope.conceptsr   r   $googlecloudsdk.command_lib.util.apisr   r   r   r*   r#   r$   rE   rC   rD   rW   rY   r[   r_   rf   ri   rl   ro   rx   r{   r   r^   r   r   <module>r      s    . ( = , 5 6 :$,!.0"&0BD888		r   