
    1                     Z   S r SSKJr  SSKJr  SrSSKr\R                  R                  S5      S:X  a%  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  O$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rSrSrSrSrSrSrS\< S\< S3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'S&r(S'r)S(r*S)r+S*r, " S+ S,\-5      r. " S- S.\
R^                  5      r0 " S/ S0\
R^                  5      r1 " S1 S2\
R^                  5      r2 " S3 S4\
R^                  5      r3S:S5 jr4S6 r5S7 r6S8 r7S9 r8g);a  QueueInfo tools.

QueueInfo is a library for working with QueueInfo records, describing task queue
entries for an application. QueueInfo loads the records from `queue.yaml`. To
learn more about the parameters you can specify in `queue.yaml`, review the
`queue.yaml reference guide`_.

.. _queue.yaml reference guide:
   https://cloud.google.com/appengine/docs/python/config/queueref
    )absolute_import)unicode_literalszarb@google.com (Anthony Baxter)NAPPENGINE_RUNTIMEpython27)appinfo)
validation)yaml_builder)yaml_listener)yaml_object)taskqueue_service_pbz^[A-Za-z0-9-]{0,499}$z^(0|[0-9]+(\.[0-9]*)?/[smhd])z^([0-9]+(\.[0-9]*)?[BKMGT]?)z(True)|(False)z(pull)|(push)z(?!-)[a-z\d\-]{1,63}z(?!-)[a-z\d\-]{1,100}z^(?:(?:(z)\.)?)(z)$queuenameratebucket_sizemodetargetmax_concurrent_requeststotal_storage_limitresume_paused_queuesBKMGTretry_parameterstask_retry_limittask_age_limitmin_backoff_secondsmax_backoff_secondsmax_doublingsacl
user_emailwriter_emailc                       \ rS rSrSrSrg)MalformedQueueConfigurationb   z7The configuration file for the task queue is malformed. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r#       -lib/googlecloudsdk/appengine/api/queueinfo.pyr!   r!   b   s    ?r*   r!   c                   >   \ rS rSrSr\\R                  " \R                  5      \	\R                  " \R                  " 5       5      \\R                  " \R                  5      \\R                  " \R                  5      \\R                  " \R                  5      0rSrg)RetryParametersf   z7Specifies the retry parameters for a single task queue.r#   N)r$   r%   r&   r'   r(   TASK_RETRY_LIMITr   OptionalTYPE_INTTASK_AGE_LIMIT	TimeValueMIN_BACKOFF_SECONDS
TYPE_FLOATMAX_BACKOFF_SECONDSMAX_DOUBLINGS
ATTRIBUTESr)   r#   r*   r+   r-   r-   f   s}    ?
++J,?,?@j))**>*>*@A:..z/D/DE:..z/D/DEZ(()<)<=*r*   r-   c                       \ rS rSrSr\\R                  " \R                  5      \	\R                  " \R                  5      0r
Srg)Aclq   z9Controls the access control list for a single task queue.r#   N)r$   r%   r&   r'   r(   
USER_EMAILr   r0   TYPE_STRWRITER_EMAILr8   r)   r#   r*   r+   r:   r:   q   s8    A*%%j&9&9:J''
(;(;<*r*   r:   c                   d   \ rS rSrSr\\\\R                  " \
5      \\R                  " \5      \\R                  " \R                  5      \\R                  " \R                  5      \\R                  " \5      \\R                  " \R&                  " \5      5      \\R                  " \5      0rSrg)
QueueEntryy   zDescribes a single task queue.r#   N)r$   r%   r&   r'   r(   NAME_NAME_REGEXRATEr   r0   _RATE_REGEXMODE_MODE_REGEXBUCKET_SIZEr1   MAX_CONCURRENT_REQUESTSRETRY_PARAMETERSr-   ACLRepeatedr:   TARGET_VERSION_REGEXr8   r)   r#   r*   r+   r@   r@   y   s    &
K
J,
J,:&&z':':;z22:3F3FG
++O<	:z22378 j!!.1*r*   r@   c                       \ rS rSrSr\R                  \R                  " \R                  5      \
\R                  " \5      \\R                  " \5      \\R                  " \R                  " \5      5      0rSrg)QueueInfoExternal   z6Describes all of the queue entries for an application.r#   N)r$   r%   r&   r'   r(   r   APPLICATIONr   r0   APPLICATION_RE_STRINGTOTAL_STORAGE_LIMIT_TOTAL_STORAGE_LIMIT_REGEXRESUME_PAUSED_QUEUES_RESUME_PAUSED_QUEUESQUEUErL   r@   r8   r)   r#   r*   r+   rP   rP      se    >:..w/L/LM:../IJJ//0EFZ  !4!4Z!@A	*r*   rP   c                 B   [         R                  " [        5      n[        R                  " U5      n[
        R                  " U5      nUR                  U 5        UR                  5       n [        U 5      S:  a  [        S5      e[        U 5      S:  a  [        S5      eU S   $ )zLoads a `queue.yaml` file/string and returns a `QueueInfoExternal` object.

Args:
  queue_info: The contents of a `queue.yaml` file, as a string.
  open_fn: Function for opening files. Unused.

Returns:
  A `QueueInfoExternal` object.
   zEmpty queue configuration.z*Multiple queue: sections in configuration.r   )r   ObjectBuilderrP   r	   BuilderHandlerr
   EventListenerParse
GetResultslenr!   )
queue_infoopen_fnbuilderhandlerlisteners        r+   LoadSingleQueuerf      s     %%&78'''0'((1(
..!!#*_q
%&B
CC_q
% ': ; ;	Ar*   c                 X   U S:X  a  gU R                  S5      n[        U5      S:w  a  [        SU -  5      eUu  p# [        U5      nUS	;  a  [        SU < SU< S
35      eUS:X  a  U$ US:X  a  US-  $ US:X  a  US-  $ US:X  a  US-  $ g! [         a    [        SU < SU< S35      ef = f)aJ  Parses a rate string in the form `number/unit`, or the literal `0`.

The unit is one of `s` (seconds), `m` (minutes), `h` (hours) or `d` (days).

Args:
  rate: The string that contains the rate.

Returns:
  A floating point number that represents the `rate/second`.

Raises:
  MalformedQueueConfiguration: If the rate is invalid.
0g        /   zRate "%s" is invalid.zRate "z" is invalid: "z" is not a number.smhdz" is not one of s, m, h, d.sm<   h  dQ N)splitr`   r!   float
ValueError)r   elementsnumberunits       r+   	ParseRatery      s     
S[ZZ_(]a
%&=&D
EE,&:6]F
 

%+/'7 8 8 
S[M	S["9	S[7	S[<    
 :
%+/'9 : ::s   B
 
B)c                    U R                  5       n U (       d  [        S5      e U S   [        ;   a7  [        U SS 5      n[         H  nU S   U:w  a  US-  nM  [	        U5      s  $    g[	        U 5      $ ! [
         a    [        SU -  5      ef = f)a  Parses a string representing the storage bytes limit.

Optional limit suffixes are:
    - `B` (bytes)
    - `K` (kilobytes)
    - `M` (megabytes)
    - `G` (gigabytes)
    - `T` (terabytes)

Args:
  limit: The string that specifies the storage bytes limit.

Returns:
  An integer that represents the storage limit in bytes.

Raises:
  MalformedQueueConfiguration: If the limit argument isn't a valid Python
      double followed by an optional suffix.
z&Total Storage Limit must not be empty.r   i   z$Total Storage Limit "%s" is invalid.N)stripr!   BYTE_SUFFIXESrt   intru   )limitrw   cs      r+   ParseTotalStorageLimitr      s    ( ++-%	
%&N
OO-RyM!U1R[!f!9>D=&V
	  Z	 -
%&L&+', - --s   A A3 %A3 (
A3 3Bc                 d   U R                  5       n U (       d  [        S5      eU S   nUS;  a  [        S5      e [        U SS 5      nUS:X  a  [        U5      $ US:X  a  [        US-  5      $ US	:X  a  [        US
-  5      $ US:X  a  [        US-  5      $ g! [         a    [        SU -  5      ef = f)a  Parses a string representing the task's age limit (maximum allowed age).

The string must be a non-negative integer or floating point number followed by
one of `s`, `m`, `h`, or `d` (seconds, minutes, hours, or days, respectively).

Args:
  age_limit: The string that contains the task age limit.

Returns:
  An integer that represents the age limit in seconds.

Raises:
  MalformedQueueConfiguration: If the limit argument isn't a valid Python
      double followed by a required suffix.
z!Task Age Limit must not be empty.r{   rk   zJTask Age_Limit must be in s (seconds), m (minutes), h (hours), or d (days)r   rl   rm   rn   ro   rp   rq   rr   zTask Age_Limit "%s" is invalid.N)r|   r!   rt   r~   ru   )	age_limitrx   rw   s      r+   ParseTaskAgeLimitr      s      oo)	
%&I
JJ	2$	
% 'L M M19Qr?#Fs{[s{"s{$s{%    
 1
%&G&/'0 1 11s   B B -B B B/c                 |   [         R                  " 5       nU R                  b$  UR                  [	        U R                  5      5        U R
                  b$  UR                  [        U R
                  5      5        U R                  b$  UR                  [        U R                  5      5        U R                  b$  UR                  [        U R                  5      5        U R                  b$  UR                  [	        U R                  5      5        UR                  5       (       aV  UR!                  5       (       dA  UR#                  5       UR%                  5       :  a  UR                  UR#                  5       5        UR                  5       (       dV  UR!                  5       (       aA  UR#                  5       UR%                  5       :  a  UR                  UR%                  5       5        UR'                  5       (       a  UR)                  5       S:  a  [+        S5      eUR-                  5       (       a  UR/                  5       S:  d  [+        S5      eUR                  5       (       a  UR#                  5       S:  a  [+        S5      eUR!                  5       (       a  UR%                  5       S:  a  [+        S5      eUR1                  5       (       a  UR                  5       S:  a  [+        S5      eUR                  5       (       aB  UR!                  5       (       a-  UR#                  5       UR%                  5       :  a  [+        S5      eU$ )a  Populates a `TaskQueueRetryParameters` from a `queueinfo.RetryParameters`.

Args:
  retry: A `queueinfo.RetryParameters` that is read from `queue.yaml` that
      describes the queue's retry parameters.

Returns:
  A `taskqueue_service_pb.TaskQueueRetryParameters` proto populated with the
  data from `retry`.

Raises:
  MalformedQueueConfiguration: If the retry parameters are invalid.
r   z,Task retry limit must not be less than zero.z)Task age limit must be greater than zero.z/Min backoff seconds must not be less than zero.z/Max backoff seconds must not be less than zero.z)Max doublings must not be less than zero.z>Min backoff sec must not be greater than than max backoff sec.)r   TaskQueueRetryParametersr   set_retry_limitr~   r   set_age_limit_secr   r   set_min_backoff_secrt   r   set_max_backoff_secr   set_max_doublingshas_min_backoff_sechas_max_backoff_secmin_backoff_secmax_backoff_sechas_retry_limitretry_limitr!   has_age_limit_secage_limit_sechas_max_doublings)retryparamss     r+   TranslateRetryParametersr   "  s     88:&
'
3u5567
%
.u/C/CDE
*
uU%>%>?@
*
uU%>%>?@
$
S!4!456 !!&*D*D*F*F&"8"8"::  !7!7!9:		#	#	%	%&*D*D*F*F&"8"8"::  !7!7!9: &"4"4"6":
%68 8 (<(<(>(B
%35 5 !!f&<&<&>&B
%9; ; !!f&<&<&>&B
%9; ; F$8$8$:Q$>
%35 5   ""v'A'A'C'C!7!7!99
%HJ J 
-r*   )N)9r(   
__future__r   r   
__author__osenvirongetgoogle.appengine.apir   r   r	   r
   r   google.appengine.api.taskqueuer   googlecloudsdk.appengine.api&googlecloudsdk.appengine.api.taskqueuerC   rE   rU   rW   rG   MODULE_ID_RE_STRINGMODULE_VERSION_RE_STRINGrN   rX   rB   rD   rH   rF   rM   rI   rT   rV   r}   rJ   r/   r2   r4   r6   r7   rK   r<   r>   	Exceptionr!   	Validatedr-   r:   r@   rP   rf   ry   r   r   r   r#   r*   r+   <module>r      sp   	 ' '.
 
 ::>>%&*4*-/0.A25786I '.<  *  .  4 -E,?A 		3 + - % % !+ + 
@) @j** *

 %%  
,, 0%!P%-P$1NAr*   