
                         h    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 r	S r
S	 rS
 rS rS rg)z9Code that's shared between multiple url-maps subcommands.    )absolute_import)division)unicode_literals)operation_utils)scopec                     [         R                  " U S5      (       d3  [        U5      (       a  UR                  U l        OU R
                  U l        UR                  X5      $ )a-  Parses the backend service that is pointed to by a URL map from args.

This function handles parsing a regional/global backend service that is
pointed to by a regional/global URL map.

Args:
  args: The arguments provided to the url-maps command
  backend_service_arg: The ResourceArgument specification for the backend
    service argument.
  url_map_ref: The resource reference to the URL MAP. This is returned by
    parsing the URL map arguments provided.
  resources: ComputeApiHolder resources.

Returns:
  Backend service reference parsed from args.
default_service)compute_scopeIsSpecifiedForFlagIsRegionalUrlMapRefregiondefault_service_regionr	   global_default_serviceResolveAsResource)argsbackend_service_argurl_map_ref	resourcess       Alib/googlecloudsdk/command_lib/compute/url_maps/url_maps_utils.pyResolveUrlMapDefaultServicer      sP    ( 
	)	)$0A	B	B;''$/$6$6d!$($8$8d!		.	.t	??    c                     [         R                  " U S5      (       d3  [        U5      (       a  UR                  U l        OU R
                  U l        UR                  X5      $ )a  Parses the backend bucket that is pointed to by a URL map from args.

This function handles parsing a backend bucket that is pointed to by a URL
map. If neither the --default-backend-bucket-region,
--global-default-backend-bucket is specified, the scope is set to the scope
of url map.

Args:
  args: The arguments provided to the url-maps command
  backend_bucket_arg: The ResourceArgument specification for the backend
    bucket argument.
  url_map_ref: The resource reference to the URL MAP. This is returned by
    parsing the URL map arguments provided.
  resources: ComputeApiHolder resources.

Returns:
  Backend bucket reference parsed from args.
default_backend_bucket)r
   r   r   r   default_backend_bucket_regionr   global_default_backend_bucketr   )r   backend_bucket_argr   r   s       r   !ResolveUrlMapDefaultBackendBucketr   6   sP    , 
	)	)$0H	I	I;''+6+=+=d(+/+F+Fd(		-	-d	>>r   c                 (    U R                  5       S:H  $ )z2Returns True if the URL Map reference is regional.compute.regionUrlMaps
Collectionr   s    r   r   r   U   s     
			!%<	<<r   c                 (    U R                  5       S:H  $ )z0Returns True if the URL Map reference is global.zcompute.urlMapsr    r"   s    r   IsGlobalUrlMapRefr$   [   s     
			!%6	66r   c                 ^   UR                  5       S:X  aM  U R                  R                  R                  U R                  R
                  " S0 UR                  5       D65      $ U R                  R                  R                  U R                  R                  " S0 UR                  5       D65      $ )zSend Url Maps get request.r    )	r!   apitools_clientregionUrlMapsGetmessagesComputeRegionUrlMapsGetRequestAsDicturlMapsComputeUrlMapsGetRequest)clientr   s     r   SendGetRequestr0   a   s    !88!!//3366N9K9K9MN  
			'	'	+	+oo..F1C1C1EF
 r   c                     UR                  5       S:X  a  [        R                  " 5       nO[        R                  " 5       n[        R                  " XX%X45      $ )aS  Waits for the URL map operation to finish.

Args:
  resources: The resource parser.
  service: apitools.base.py.base_api.BaseApiService, the service representing
    the target of the operation.
  operation: The operation to wait for.
  url_map_ref: The URL map reference.
  message: The message to show.

Returns:
  The operation result.
r   )r!   r   GetRegionalOperationsCollectionGetGlobalOperationsCollectionWaitForOperation)r   service	operationr   message
collections         r   r4   r4   l   sL     !88 @@BJ >>@J		)	))
 r   N)__doc__
__future__r   r   r   "googlecloudsdk.command_lib.computer   r   r
   r   r   r   r$   r0   r4   r&   r   r   <module>r<      s9    @ &  ' > E@:?>=7r   