
    1                     d    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 r
S	 rS
 rS rg)zFHelper class for generating Cloud Logging URLs for Dataproc resources.    )absolute_import)division)unicode_literalsN)
properties)parsec                  Z    Sn SnSR                  U [        R                  " SU05      5      $ )zfReturns the base URL for the Cloud Logging console.

This is used when parsing batch resource failed.
+https://console.cloud.google.com/logs/query$resource.type="cloud_dataproc_batch"z{}?{}query)formatr   	urlencode)logging_basebatch_resource_filters     Flib/googlecloudsdk/api_lib/dataproc/poller/cloud_console_url_helper.pyget_plain_batch_logging_urlr      s:    
 ?,@	oo
( 	
     c                    [         R                  " SU R                  5      nU(       d
  [        5       $ UR	                  S5      nUR	                  S5      nSnSnSU 3nSU S3n[
        R                  R                  R                  R                  5       nS	U S
U S3n	SR                  U[        R                  " SUS-   U-   S-   U	-   05      U5      $ )zReturns a Cloud Logging URL for the given batch.

Args:
  batch: The batch to get the Cloud Logging URL for.

Returns:
  A Cloud Logging URL for the given batch or a plain url without batch info.
zJprojects/(?P<project_id>[^/]+)/locations/[^/]+/batches/(?P<batch_id>[^/]+)
project_idbatch_idr	   r
   project=zresource.labels.batch_id=""zlog_name="projects/z/logs/dataproc.z
%2Foutput"z{}?{}&{}r   
)rematchnamer   groupr   VALUEScoreuniverse_domainGetr   r   r   )
batchr   r   r   r   r   project_querybatch_id_filterr   driver_output_filters
             r   get_batch_logging_urlr%   ,   s     ((Sjj% 
&(({{<(*[[$(>,@ZL)-0
!</%%**::>>@/.zl//IZZde			oo
#   %	% 	 
 r   c                  
    Sn U $ )ziReturns the base URL for the Dataproc Batches console.

This is used when parsing batch resource failed.
z1https://console.cloud.google.com/dataproc/batches )dataproc_batches_bases    r   get_plain_batches_list_urlr)   U   s    
 N	r   c                     [         R                  " SU R                  5      nU(       d
  [        5       $ UR	                  S5      nUR	                  S5      nUR	                  S5      nSU SU S3nSU 3nUS	-   U-   $ )
z1Returns a Dataproc Batch URL for the given batch.zXprojects/(?P<project_id>[^/]+)/locations/(?P<location>[^/]+)/batches/(?P<batch_id>[^/]+)r   r   locationz2https://console.cloud.google.com/dataproc/batches//z/summaryr   ?)r   r   r   r)   r   )r!   r   r   r   r+   dataproc_batch_urlr"   s          r   get_dataproc_batch_urlr/   ^   s    
((ajj% 
%''{{<(*[[$([[$(KH:UVW_V``hiZL)-	c	!M	11r   )__doc__
__future__r   r   r   r   googlecloudsdk.corer   six.moves.urllibr   r   r%   r)   r/   r'   r   r   <module>r4      s2     M &  ' 	 * " &R2r   