
    1                     d    d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 d Z
d	 Zd
 Zd Zy)zFHelper class for generating Cloud Logging URLs for Dataproc resources.    )absolute_import)division)unicode_literalsN)
properties)parsec                  X    d} d}dj                  | t        j                  d|i            S )zjReturns 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                    t        j                  d| j                        }|s
t               S |j	                  d      }|j	                  d      }d}d}d| }d| d}t
        j                  j                  j                  j                         }d	| d
| d}	dj                  |t        j                  d|dz   |z   dz   |	z   i      |      S )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                  
    d} | S )zmReturns 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                     t        j                  d| j                        }|s
t               S |j	                  d      }|j	                  d      }|j	                  d      }d| d| d}d| }|d	z   |z   S )
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   