
                            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dlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlm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 ej4                  j6                  j8                  j:                  Z G d dej>                        Z  G d dej>                        Z! G d dej>                        Z" G d de#      Z$d Z%d Z&d Z'dOdZ(dOdZ)d Z*d  Z+d! Z,d" Z-d# Z.d$ Z/d%e	j`                  jb                  d&fd'Z2d( Z3d) Z4e	j`                  jb                  fd*Z5e	j`                  jb                  fd+Z6e	j`                  jb                  fd,Z7dPd-Z8dPd.Z9d/ Z:	 dPd0Z;dPd1Z<d2 Z=d3 Z>d4 Z?d5 Z@d6 ZAd7 ZBd8 ZCd9 ZDd: ZEd; ZF	 	 	 	 	 	 dQd<ZGd= ZHd> ZId? ZJd@ ZKdA ZLdB ZMdC ZNdD ZOdE ZPdF ZQdG ZRdH ZSdI ZTdJ ZUdK ZVdL ZWdM ZXdN ZYy)Rz;Utilities for parsing arguments to `gcloud tasks` commands.    )absolute_import)division)unicode_literalsN)encoding)base)parser_errors)app)	constants)
exceptions)
properties)	resources)
console_io)http_encoding)filter)mapc                       e Zd ZdZy)NoFieldsSpecifiedErrorzAError for when calling an update method with no fields specified.N__name__
__module____qualname____doc__     /lib/googlecloudsdk/command_lib/tasks/parsers.pyr   r   )   s    Ir   r   c                       e Zd ZdZy)FullTaskUnspecifiedErrorz<Error parsing task without specifing the queue or full path.Nr   r   r   r   r   r   -   s    Dr   r   c                       e Zd ZdZy)"NoFieldsSpecifiedForHttpQueueErrorzQError for calling a create-http-queue method with no override field specified.
  Nr   r   r   r   r   r   1   s    r   r   c                   d    e Zd ZdZeej                  j                  fd       Zd Z	d Z
d Zd Zy)QueueUpdatableConfigurationz+Data Class for queue configuration updates.c                     |        }i |_         i |_        i |_        i |_        i |_        d|_        d|_        d|_        d|_        d|_	        |t        j                  k(  rddd|_         d|_        |S |t        j                  k(  r@|t        j                  j                  k(  rMdddddd	|_         d
dd|_        ddi|_        dddddddd|_        d|_        d|_        d|_        d|_        |S |t        j                  j                   k(  r^dddddd	|_         dddd|_        ddi|_        dddddddd|_        ddi|_        d|_        d|_        d |_        d|_        d!|_	        |S dddddd	|_         ddd"|_        ddi|_        dddddddd|_        ddi|_        d|_        d|_        d#|_        d|_        d!|_	        |S )$z>Creates QueueUpdatableConfiguration from the given parameters.NmaxAttemptsmaxRetryDuration)max_attemptsmax_retry_durationretryConfigmaxDoublings
minBackoff
maxBackoffr%   r&   max_doublingsmin_backoffmax_backoffmaxTasksDispatchedPerSecondmaxConcurrentTasks)max_tasks_dispatched_per_secondmax_concurrent_tasksrouting_overrideappEngineRoutingOverrideuriOverride
httpMethodheaderOverrideszoauthToken.serviceAccountEmailzoauthToken.scopezoidcToken.serviceAccountEmailzoidcToken.audiencehttp_uri_overridehttp_method_overridehttp_header_override)http_oauth_service_account_email_overridehttp_oauth_token_scope_override(http_oidc_service_account_email_override!http_oidc_token_audience_override
rateLimitsappEngineHttpTarget
httpTargetmaxDispatchesPerSecondmaxConcurrentDispatchesmaxBurstSizemax_dispatches_per_secondmax_concurrent_dispatchesmax_burst_sizelog_sampling_ratiosamplingRatioappEngineHttpQueuestackdriverLoggingConfig)rG   rH    )retry_configrate_limitsapp_engine_routing_overridehttp_targetstackdriver_logging_configretry_config_mask_prefixrate_limits_mask_prefix'app_engine_routing_override_mask_prefixhttp_target_mask_prefix&stackdriver_logging_config_mask_prefixr
   
PULL_QUEUE
PUSH_QUEUEr   ReleaseTrackALPHABETA)cls
queue_typerelease_trackconfigs       r   FromQueueTypeAndReleaseTrackz8QueueUpdatableConfiguration.FromQueueTypeAndReleaseTrack9   s   
 UFFF)+F&F(*F%&*F#%)F"59F2%)F"48F1Y)))' 2f )6f%h Mg 
y++	+	$++11	1)"4+''
 0M$8

  :.
*
 !0"/$
  +8')5&9N6)5&` M_ D--222)"4+''
 *B)B,
  :.
*
 !0"/$
" !/-
) +8')5&9M6)5&8R5P MK *"4+''
 *B)B

  :.
*
 !0"/$
" !/-
) +8')5&9;6)5&8R5Mr   c                 *   | j                   | j                  f| j                  | j                  f| j                  | j
                  f| j                  | j                  f| j                  | j                  fg}|D cg c]  \  }}|r||f c}}S c c}}w )zEReturns the initialized configs as a list of (config, prefix) tuples.)
rO   rT   rP   rU   rQ   rV   rR   rW   rS   rX   )selfall_configs_and_prefixesra   prefixs       r   "_InitializedConfigsAndPrefixTuplesz>QueueUpdatableConfiguration._InitializedConfigsAndPrefixTuples   s     
		D99:			4778		)	)		5	5	7			4778		(	(		4	4	6  %=$<  V$<  s   ;Bc                     t               }|j                         D ]5  }||   }|rdj                  ||      ||<   n|||<   ||   |t        |      <   7 |S )zEBuild a map from each arg and its clear_ counterpart to a mask field.z{}.{})dictkeysformat_EquivalentClearArg)rd   ra   rf   fields_to_maskfieldoutput_fields         r   _GetSingleConfigToMaskMappingz9QueueUpdatableConfiguration._GetSingleConfigToMaskMapping   sa    VNE]l	 'v| Du ,u3A%3Hn(/0  r   c                     t               }| j                         D ]&  \  }}|j                  | j                  ||             ( |S )zFBuilds mapping from config fields to corresponding update mask fields.)ri   rg   updaterp   )rd   config_to_maskra   rf   s       r   GetConfigToUpdateMaskMappingz8QueueUpdatableConfiguration.GetConfigToUpdateMaskMapping   sC    VN CCED>>vvNO Fr   c                 h   t        | j                  j                               t        | j                  j                               z   t        | j                  j                               z   t        | j
                  j                               z   t        | j                  j                               z   S N)listrO   rj   rP   rQ   rR   rS   )rd   s    r   
AllConfigsz&QueueUpdatableConfiguration.AllConfigs   s    ""'')*T$2B2B2G2G2I-JJ116689:!!&&()* 0055789 :r   N)r   r   r   r   classmethodr   r[   GArb   rg   rp   rt   rx   r   r   r   r!   r!   6   s?    3 261B1B1E1EJ JX
:r   r!   c                  p    t         j                  j                  t               t        j
                        S )N
collection)r   REGISTRYParse_PROJECTr
   PROJECTS_COLLECTIONr   r   r   ParseProjectr      s.    				!	!j.. 
" 
0 0r   c                 n    t         j                  j                  | dt        it        j
                        S N
projectsIdparamsr}   )r   r~   r   r   r
   LOCATIONS_COLLECTION)locations    r   ParseLocationr      s4    				!	!H%// 
" 
1 1r   c                     t        j                  d|       }|r0dj                  |j                  d      |j                  d            S | S )a  Parses a full queue reference and returns an abridged version.

  Args:
    queue_string: A full qualifying path for a queue which includes project and
      location, e.g. projects/PROJECT/locations/LOCATION/queues/QUEUE

  Returns:
    A shortened string for the full queue ref which has only the location and
    the queue (LOCATION/QUEUE). For example:
      'projects/myproject/location/us-east1/queue/myqueue' => 'us-east1/myqueue'
  z@projects\/.*\/locations\/(?P<location>.*)\/queues\/(?P<queue>.*)z{}/{}r   queue)rematchrk   group)queue_stringr   s     r   GetConsolePromptStringr      sF     ((I% >>%++j15;;w3GHH	r   c                    | syd}	 t         j                  j                  | t        j                        }|S # t         j
                  $ rw |xs t        j                  t                     }t        |      }t         j                  j                  | |j                  |j                  dt        j                        }Y |S w xY w)a
  Parses an id or uri for a queue.

  Args:
    queue: An id, self-link, or relative path of a queue resource.
    location: The location of the app associated with the active project.

  Returns:
    A queue resource reference, or None if passed-in queue is Falsy.
  Nr|   )r   locationsIdr   )r   r~   r   r
   QUEUES_COLLECTIONRequiredFieldOmittedExceptionr	   ResolveAppLocationr   r   r   r   )r   r   	queue_refapp_locationlocation_refs        r   
ParseQueuer     s     
)	0""((4=4O4O ) QI 
 
	0	0 0Es55lnEL .L""((\%<%<&2&>&>@.. ) 0I 
0s   /8 BCCc                     |r|j                         nd}	 t        j                  j                  | t        j
                  |      S # t        j                  $ r t        d      w xY w)zParses an id or uri for a task.N)r}   r   zDMust specify either the fully qualified task path or the queue flag.)AsDictr   r~   r   r
   TASKS_COLLECTIONr   r   )taskr   r   s      r   	ParseTaskr   ,  sq    !*9&P##D/8/I/I+1 $ 3 3 
	0	0 P
"NP PPs   /A A%c                 6    | j                   r| j                   S dS )zParses an id for a task.N)task_idargss    r   ParseTaskIdr   8  s    /4/r   c                     | syt        j                  d|       }|rB|j                  d      |j                  d      |j                  d      |j                  d      gS y)z9Parses and retrieves the segments of a full KMS key name.Nzjprojects\/(?P<project>.*)\/locations\/(?P<location>.*)\/keyRings\/(?P<keyring>.*)\/cryptoKeys\/(?P<key>.*)projectr   keyringkey)r   r   r   )kms_key_namer   s     r   ParseFullKmsKeyNamer   =  s`    	
((s% IJIE	  
r   c                    | j                   r| j                   nd}d}t        | j                        }||d   }| j                  }nm| j                  ra| j                  rU| j                   rIdj	                  | j
                  r| j
                  n	t               || j                  | j                        }t               ||fS )zParses KMS key value.N   zbprojects/{kms_project_id}/locations/{location_id}/keyRings/{kms_keyring}/cryptoKeys/{kms_key_name})kms_project_idlocation_idkms_keyringr   )r   r   r   r   rk   kms_projectr   )r   r   full_kms_key_nameparse_results       r   ParseKmsUpdateArgsr   P  s    !%D+$T%6%67,
 q/K))




--|  D  D+/+;+;t''$$&&	 D  
&	33r   c                 R    | j                   r| j                   nd}t               }||fS )zParses KMS describe args.Nr   r   )r   r   
project_ids      r   ParseKmsDescribeArgsr   k  s%    !%D+z*	[	  r   c                 N    | j                   r| j                   nd}t               |fS )zParses KMS clear args.Nr   )r   r   s     r   ParseKmsClearArgsr   s  s     !%D+	[	  r   c                     | j                         }|d= t        j                  j                  d |t        j
                        }|S )NqueuesIdr   )r   r   r~   r   r
   r   )r   r   r   s      r   ExtractLocationRefFromQueueRefr   z  sG    &Z##))
6i&D&D * F,	r   FTc                    |t         j                  j                  k(  rZt        | ||      }|rt	        | ||      nd}|j                  t        | |||d      t        | |||      t        | |||      ||      S |t         j                  j                  k(  re|rt	        | ||      nd}|j                  t        | |||d      t        | |||      t        | |||      t        | ||      |t        | |||            S |rt	        | ||      nd}|j                  t        | |||d      t        | |||      t        | |||      t        | ||      |      S )zParses queue level args.NT)is_alpha)r'   r@   
pullTargetrA   rB   F)r'   r@   rM   rL   rB   type)r'   r@   rM   r4   rB   )r   r[   r\   _ParseAppEngineHttpTargetArgs_ParseHttpTargetArgsQueue_ParseRetryConfigArgs_ParseAlphaRateLimitsArgs_ParsePullTargetArgsr]   _ParseRateLimitsArgs"_ParseStackdriverLoggingConfigArgs_ParseAppEngineHttpQueueArgs_ParseQueueType"_ParseAppEngineRoutingOverrideArgs)r   r_   messages	is_updater`   
http_queueapp_engine_http_targetrR   s           r   ParseCreateOrUpdateQueueArgsr     s    d''---:j( =GT:x8D  >>)*h	D
 -*h	
 (j(IN2  
 
 ))...<FT:x8D  >>)*h	E
 (j(IN!C*h	"
 8*h
 T:xC     =GT:x8D  >>)*h	E
 (j(IN!C*h	"
 "D*h"
    r   c                    | j                   | j                   j                  nd}| j                   | j                   j                  nd}| j                   | j                   j                  nd}| j                   6| j                   j                   | j                   j                  j
                  nd}| j                   6| j                   j                   | j                   j                  j                  nd}| j                   6| j                   j                   | j                   j                  j
                  nd}| j                   6| j                   j                   | j                   j                  j                  nd}|||||||dS )zHReturns a pair of each http target attribute and its value in the queue.N)r9   r:   r;   http_oauth_email_overridehttp_oauth_scope_overridehttp_oidc_email_overridehttp_oidc_audience_override)	rB   r5   r6   r7   
oauthTokenserviceAccountEmailscope	oidcTokenaudience)queue_configr9   r:   r;   r   r   r   r   s           r   GetHttpTargetArgsr     s   
 
	 	 	, ))  
	 	 	, ((  
	 	 	, --  
!
!
-%%00< ((<<
   
!
!
-%%00< ((..
   
!
!
-%%//; '';;
   
!
!
-%%//; ''00
   -22#<#<":%@
 r   c                 0   d}	 | j                   j                  j                  }|r|S d}	 | j                   j                  j                  }|sydj                  |      }||v r|j                  |d      d   S dS # t        $ r Y aw xY w# t        $ r Y Iw xY w)a  Extracts any target (service) if it exists in the appEngineRouting field.

  Args:
    job: An instance of job fetched from the backend.
    project: The base name of the project.

  Returns:
    The target if it exists in the URL, or if it is present in the service
    attribute of the appEngineRouting field, returns None otherwise.
    Some examples are:
      'alpha.some_project.uk.r.appspot.com' => 'alpha'
      'some_project.uk.r.appspot.com' => None
  Nz.{}.r   r   )rA   appEngineRoutingserviceAttributeErrorhostrk   split)jobr   targethost_url	delimiters        r   !ExtractTargetFromAppEngineHostUrlr     s      &	$$55==F M (	&&77<<H 
mmG$),5,A	1	%a	(KtK 
 		 
 		s"    A:  B	 :	BB		BBc           	         |t         j                  j                  k(  r4|j                  | j                  t        | ||      t        | ||            S |j                  | j                  t        | ||      t        | ||            S )zParses task level args.)scheduleTimepullMessageappEngineHttpRequest)r   r   httpRequest)	r   r[   r\   Taskschedule_time_ParsePullMessageArgs#_ParseAlphaAppEngineHttpRequestArgs_ParseAppEngineHttpRequestArgs_ParseHttpRequestArgs)r   	task_typer   r`   s       r   ParseCreateTaskArgsr   '  s     d''---=='')$	8D@)X'  ( ( =='';D)<DF)$	8D	  F Fr   c                 ~    t         j                  ||      }t        | |j                         d      ryt	        d      )z2Verifies that args are valid for updating a queue.T
clear_argsNz*Must specify at least one field to update.)r!   rb   _AnyArgsSpecifiedrx   r   )r   r_   r`   updatable_configs       r   CheckUpdateArgsSpecifiedr   8  sA     1MM-! t-88:tL
KLLr   c                 P   t         j                  ||      }t        | |j                         d      }|j	                         }|D cg c]  }||   	 }}t        | d      r.| j                  t        j                  k(  r|j                  d       t        t        |            S c c}w )z3Returns the mask fields to use with the given args.Tr   r   )r!   rb   _SpecifiedArgsrx   rt   hasattrr   r
   	PULL_TASKappendsortedset)r   r_   r`   r   specified_argsargs_to_maskargmasks_fields           r   GetSpecifiedFieldsMaskr  C  s     1MM-! "
'')d<. ">>@,.<=nsc"n+=T6tyyI,?,??v	K 	!! >s   B#c                 n      fd}g }|r|D cg c]  }t        |       }}t        |||z         S c c}w )z:Returns the list of known arguments in the specified list.c                      g d}	 j                         S # t        j                  $ r  dv st         fd|D              rY y w xY w)a  Wrapper function for Namespace.IsSpecified function.

    We need this function to be support being able to modify certain queue
    attributes internally using `gcloud app deploy queue.yaml` without exposing
    the same functionality via `gcloud tasks queues create/update`.

    Args:
      arg: The argument we are trying to check if specified.

    Returns:
      True if the argument was specified at CLI invocation, False otherwise.
    r8   )rI   clear_max_burst_sizec              3   &   K   | ]  }|v  
 y wrv   r   ).0flagr  s     r   	<genexpr>z>_SpecifiedArgs.<locals>._IsSpecifiedWrapper.<locals>.<genexpr>p  s      B"1$$#+/s   F)IsSpecifiedr   UnknownDestinationExceptionany)r  http_queue_argsspecified_args_objects   ` r   _IsSpecifiedWrapperz+_SpecifiedArgs.<locals>._IsSpecifiedWrapperV  s\    O"..s3344 	:	:c B"1B ? s    +AA)rl   r   )r  	args_listr   r  clear_args_listas   `     r   r   r   S  sF    @ /7@Ay!*1-yOA	#Y%@	AA Bs   2c                 .    t        t        | ||            S )z@Returns whether there are known arguments in the specified list.)r  r   )r  r  r   s      r   r   r   |  s    	^19jI	JJr   c                 $    dj                  |       S )Nzclear_{}rk   )r  s    r   rl   rl     s    			3	r   c                    |t         j                  k(  r;t        | ddg|      r+|j                  | j                        }t        | ||       |S |t         j                  k(  r]t        | g d|      rL|j                  | j                  | j                  | j                  | j                        }t        | ||       |S yy)z6Parses the attributes of 'args' for Queue.retryConfig.r%   r&   r   )r$   r+   )r$   r(   r)   r*   N)
r
   rY   r   RetryConfigr&   _AddMaxAttemptsFieldsFromArgsrZ   r,   r-   r.   )r   r_   r   r   r   rO   s         r   r   r     s     I(((~/CD#,.''00 ( 2L!$h?I((( N#,. ''00''D4D4D## ( %L "$h?. )r   c                     | j                  d      r0| j                  |rd|_        y d|_        y | j                  |_        y y )Nr%   T)r  r%   unlimitedAttemptsr#   )r   config_objectr   s      r   r  r    sB    	n% 	*.'$&!"&"3"3m &r   c                     |t         j                  k(  r8t        | ddg|      r'|j                  | j                  | j
                        S yy)5Parses the attributes of 'args' for Queue.rateLimits.r1   r2   r   )r/   r0   N)r
   rZ   r   
RateLimitsr1   r2   r   r_   r   r   s       r   r   r     s^    I(((@57#,. $($H$H44  6 6. )r   c                     |t         j                  k(  rSt        | g d|      rBt        | d      r| j                  nd}|j                  | j                  | j                  |      S yy)r"  rF   r   rI   N)rC   rD   rE   )r
   rZ   r   r   rI   r#  rG   rH   )r   r_   r   r   rI   s        r   r   r     sx     I(((
	   't-=>D #== $ > >#  % %  )r   c                     |t         j                  k7  r,t        | dg|      r|j                  | j                        S yy)zCParses the attributes of 'args' for Queue.stackdriverLoggingConfig.rJ   r   )rK   N)r
   rY   r   StackdriverLoggingConfigrJ   r$  s       r   r   r     sN     I(((34K,,-- - / / L )r   c                 P    |t         j                  k(  r|s|j                         S yy)z5Parses the attributes of 'args' for Queue.pullTarget.N)r
   rY   
PullTarget)unused_argsr_   r   r   s       r   r   r     s)    9'''	   1:'r   c                     t        | d      r| j                  t        j                  k(  s|t        j                  k(  r"|s |j                  j
                  j                  S |j                  j
                  j                  S )z/Parses the attributes of 'args' for Queue.type.r   )r   r   r
   rY   r   TypeValueValuesEnumPULLPUSHr$  s       r   r   r     s[     tVi.B.B!BY))))>>--222		+	+	0	00r   c                 n    |t         j                  k(  r"t        | ||      }|y|j                  |      S y)z>Parses the attributes of 'args' for Queue.appEngineHttpTarget.Nr4   )r
   rZ   r   AppEngineHttpTargetr   r_   r   r3   s       r   r   r     sK    9'''9j($''!1 ( 3 3 (r   c                 P   |t         j                  k(  rt        | |      }| j                  d      r3|j                  j                  | j                  j                               nd}t        | |      }t        | |      }||||y|j	                  |t        | |      |||      S y)z5Parses the attributes of 'args' for Queue.HttpTarget.r:   N)r5   r7   r6   r   r   )r
   rZ   _ParseHttpRoutingOverrideArgsr  
HttpTargetHttpMethodValueValuesEnumr:   upper_ParseHttpTargetOAuthArgs_ParseHttpTargetOidcArgs_ParseHttpTargetHeaderArg)r   r_   r   uri_overridehttp_methodoauth_token
oidc_tokens          r   r   r     s    9'''0x@L
 23 	55%%++-	/9= 
 ,D(;K)$9J 	 1$A   ' (r   c                 h    |t         j                  k(  rt        | ||      }|j                  |      S y)z=Parses the attributes of 'args' for Queue.appEngineHttpQueue.r0  N)r
   rZ   r   AppEngineHttpQueuer2  s       r   r   r     sD    9'''9j( &&!1 '  	 (r   c                     |t         j                  k(  r.| j                  d      r |j                  di | j                  S yy)z5Parses the attributes of 'args' for AppEngineRouting.r3   Nr   )r
   rZ   r  AppEngineRoutingr3   )r   r_   r   s      r   r   r     sC    9'''*+&X&&?)>)>?? (r   c                 T    | j                  d      rt        dd|i| j                  S y)z1Parses the attributes of 'args' for HTTP Routing.r9   r   Nr   )r  _ParseUriOverrider9   r   r   s     r   r4  r4    s-    	)*IhI$2H2HII	r   c           	      B   |r)| j                   j                  |j                               nd}|rt        |      nd}|r)| j                   j	                  |j                               nd}| j                  |||| j                  |      | j                  |      |      S )z1Parses the attributes of 'args' for URI Override.N)path)queryParams)schemer   portpathOverridequeryOverrideuriOverrideEnforceMode)UriOverrideSchemeValueValuesEnumr7  int%UriOverrideEnforceModeValueValuesEnumPathOverrideQueryOverride)r   rI  r   rJ  rG  querymodeuri_override_enforce_modes           r   rD  rD    s     
 00@ 	 T$ 
 @@N  
		((d(3**u*=6 
 
8 8r   c                 v    |t         j                  k(  r&|j                  t        |       | j                        S y )N)payloadtag)r
   r   PullMessage_ParsePayloadArgsrY  )r   r   r   s      r   r   r   7  s5    )%%%(9$(?TXXNN &r   c           
         |t         j                  k(  r| j                  r |j                  di | j                  nd}| j	                  d      r3|j
                  j                  | j                  j                               nd}|j                  ||t        |       | j                  t        | |j
                  j                              S y)>Parses the attributes of 'args' for Task.appEngineHttpRequest.Nmethod)r   r6   rX  relativeUrlheadersr   )r
   APP_ENGINE_TASKroutingrB  r  AppEngineHttpRequestr6  r^  r7  r[  url_ParseHeaderArgHeadersValuer   r   r   rb  r<  s        r   r   r   <  s    )+++59\\!!!1DLL1t  !% 0 0 : 00JJ@D (( [!$'TXX ( = = J JL ) M M ,r   c                     | j                  d      r"t        j                  | j                  d      }n| j                  d      r| j                  }ny t        j                  |      S )Npayload_fileFbinarypayload_content)r  r   ReadFromFileOrStdinri  rl  r   Encode)r   rX  s     r   r[  r[  J  sV    	n%,,T->->uMG)*""G			g	&&r   c           
         |t         j                  k(  r| j                  r |j                  di | j                  nd}| j	                  d      r3|j
                  j                  | j                  j                               nd}|j                  ||t        |       | j                  t        | |j
                  j                              S y)r]  Nr^  )r   r6   bodyrelativeUrir`  r   )r
   ra  rb  rB  r  rc  r6  r^  r7  _ParseBodyArgsrelative_urire  rf  rg  s        r   r   r   T  s    )+++59\\!!!1DLL1t  !% 0 0 : 00JJ@D (( [D!t/@/@ ( = = J JL ) M M ,r   c                 n   |t         j                  k(  r| j                  d      r3|j                  j	                  | j
                  j                               nd}|j                  t        | |j                  j                        |t        |       | j                  t        | |      t        | |            S y)z5Parses the attributes of 'args' for Task.httpRequest.r^  N)r`  r6   rp  rd  r   r   )r
   	HTTP_TASKr  HttpRequestr6  r^  r7  re  rf  rr  rd  _ParseOAuthArgs_ParseOidcArgs)r   r   r   r<  s       r   r   r   b  s    )%%% $ 0 0 : ''AA@D h&:&:&G&GH^D%9txx"42 x0	   2 2 &r   c                     | j                  d      r"t        j                  | j                  d      }n| j                  d      r| j                  }ny t        j                  |      S )N	body_fileFrj  body_content)r  r   rm  rz  r{  r   rn  )r   rp  s     r   rr  rr  n  sS    	k"))$..GD'D			d	##r   c                 t    | j                  d      r'|j                  | j                  | j                        S y )Noauth_service_account_emailr   r   )r  
OAuthTokenr}  oauth_token_scoperE  s     r   rw  rw  x  s@    	34 <<$$  & & r   c                 t    | j                  d      r'|j                  | j                  | j                        S y )Noidc_service_account_emailr   r   )r  	OidcTokenr  oidc_token_audiencerE  s     r   rx  rx    s@    	23 ;;))  + + r   c                 t    | j                  d      r'|j                  | j                  | j                        S y )Nr<   r~  )r  r  r<   r=   rE  s     r   r8  r8    s@    	AB JJ22  4 4 r   c                 t    | j                  d      r'|j                  | j                  | j                        S y )Nr>   r  )r  r  r>   r?   rE  s     r   r9  r9    s@    	@A II77  9 9 r   c                     | j                   rCt        t        | j                         D ci c]  \  }}||
 }}}t        j                  ||      S y c c}}w rv   )headerr   _SplitHeaderArgValuer   DictToAdditionalPropertyMessage)r   headers_valuekvheaders_dicts        r   re  re    sN    	[[%()=t{{%KL%KTQAqD%KLL33L-PP Ls   Ac                 P    | j                  dd      \  }}||j                         fS )N:r   )r   lstrip)header_arg_valuer   values      r   r  r    s)    %%c1-*#u	elln	r   c                 x   g }| j                  d      rt        t        | j                        D ci c]  \  }}||
 }}}t	        |j                               }|D ]U  \  }}|j                  |j                  |j                         |j                                     }	|j                  |	       W |S c c}}w )zCConverts header values into a list of headers and returns the list.r;   )r   r  )r  )
r  r   r  r;   r   itemsHeaderOverrideHeaderencoder   )
r   r   map_r  r  r  r  r   r  header_overrides
             r   r:  r:    s    	$	,-143L3LMMA1M   <%%'(E
U //SZZ\H 0 Jo
kk/" 
 
+s   B6c                 $    dj                  |       S )Nz{}sr  )lease_durations    r   FormatLeaseDurationr    s    	n	%%r   c                 v    | j                   ry| j                  d      rdj                  | j                        S y )Nztag_function=oldest_tag()rY  ztag="{}")
oldest_tagr  rk   rY  r   s    r   ParseTasksLeaseFilterFlagsr    s4    	__&	eTXX&& r   c                     t         j                  j                  | j                  dt        it
        j                        j                         S r   )r   r~   r   namer   r
   r   SelfLink)r   s    r   QueuesUriFuncr    sA    				!	!jjH%,, 
" 
. /7hj9r   c                     t         j                  j                  | j                  dt        it
        j                        j                         S r   )r   r~   r   r  r   r
   r   r  r   s    r   TasksUriFuncr    sA    				!	!
iiH%++ 
" 
- .6XZ8r   c                     t         j                  j                  | j                  dt        it
        j                        j                         S r   )r   r~   r   r  r   r
   r   r  r  s    r   LocationsUriFuncr    sA    				!	!
iiH%// 
" 
1 2:<r   rv   )F)NNNNNN)Zr   
__future__r   r   r   r   apitools.base.pyr   googlecloudsdk.callioper   r    googlecloudsdk.command_lib.tasksr	   r
   googlecloudsdk.corer   r   r   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   six	six.movesr   r   VALUEScorer   	GetOrFailr   Errorr   r   r   objectr!   r   r   r   r   r   r   r   r   r   r   r   r[   rz   r   r   r   r   r   r  r   r   rl   r   r  r   r   r   r   r   r   r   r   r   r4  rD  r   r   r[  r   r   rr  rw  rx  r8  r9  re  r  r:  r  r  r  r  r  r   r   r   <module>r     s   B &  ' 	 % ( 1 0 6 * * ) 2 2 
   !!))33JZ-- JEz// E)9)9 
v:& v:r01*6	P0
&46!! ##&&?D;|"LL '+&7&7&:&:F$ ,0+<+<+?+?M *.):):)=)=" &BRK
 
 $).	46%"/!13: " 80O
M'M	2$Q
"&'98<r   