
                             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SKJ	r	  SSK
Jr  SS	KJr   " S
 S\	R                  5      rg)z#The configs waiters create command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)flags)logc                   <    \ rS rSrSrSS0r\S 5       rS rS r	Sr
g	)
Create   zmCreate waiter resources.

This command creates a new waiter resource with the specified name and
parameters.
EXAMPLESa  
          To create a waiter in "my-config" with success and failure paths
          nested under "/status", run:

            $ {command} my-waiter --config-name=my-config --timeout=15m --success-cardinality-path=/status/success --success-cardinality-number=5 --failure-cardinality-path=/status/failure --failure-cardinality-number=1

          This waiter will wait for at most 15 minutes for the first of two
          possible scenarios: 1) five or more variables are written to the
          /status/success/ path; or 2) one or more variables are written to the
          /status/failure/ path.

          To create a waiter without a failure path, run:

            $ {command} my-waiter --config-name=my-config --timeout=15m --success-cardinality-path=/status/success --success-cardinality-number=5

          This waiter will wait until 5 or more success variables are written,
          or the 15 minute timeout elapses.
          c           	         [         R                  " U 5        [        R                  R	                  U 5        U R                  S[        R                  " SSR                  [        R                  5      S9SSS9  U R                  SS	SS
9  U R                  SS[        R                  " SS9SS9  U R                  SSS9  U R                  SS[        R                  " SS9SS9  U R                  SSS9  g)zArgs is called by calliope to gather arguments for this command.

Args:
  parser: An argparse parser that you can use to add arguments that go
      on the command line after this command. Positional arguments are
      allowed.
z	--timeout1s{0}s)lower_boundupper_boundTz        The amount of time to wait before failing with DEADLINE_EXCEEDED.
        See $ gcloud topic datetimes for information on duration formats.
        )typerequiredhelpz--success-cardinality-pathz-The path where success variables are written.)r   r   z--success-cardinality-numberz1The minimum required number of success variables.   )r   )r   r   defaultz--failure-cardinality-pathz-The path where failure variables are written.)r   z--failure-cardinality-numberz1The minimum required number of failure variables.namezThe waiter name.N)r	   AddRequiredConfigFlagr   
ASYNC_FLAGAddToParseradd_argumentr   Durationformatr   MAX_WAITER_TIMEOUT
BoundedInt)parsers    4lib/surface/runtime_config/configs/waiters/create.pyArgsCreate.Args9   s    
'OO'
!!d.4mm&*&=&=/?@   	 $<   &@##2	   $<  > &@##2	   %78    c                    [         R                  " 5       n[         R                  " 5       n[         R                  " UR                  U5      nUR
                  nUR                  nUR                  UR                  UR                  UR                  S9S9nUR                  (       a2  UR                  UR                  UR                  UR                  S9S9nOSnUR                  UR                  [         R                  " XV5      UR!                  UR#                  5       SR%                  UR&                  5      UUS9S95      n	[(        R*                  " U5        UR,                  (       aI  X@l        UR0                  R2                  R5                  UR#                  5       S9n
UR7                  U
5      n	O?SU l        [         R8                  " U5      n	[         R:                  " U	5      (       a  SU l        [         R>                  " U	5      $ )	a  Run 'runtime-configs waiters create'.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
      with.

Returns:
  The associated waiter operation.

Raises:
  HttpException: An http error response was received while executing api
      request.
)pathnumber)cardinalityNr   )r   timeoutsuccessfailure)parentwaiter)r      ) r   WaiterClientMessagesParseWaiterNamer   
projectsId	configsIdEndConditionCardinalitysuccess_cardinality_pathsuccess_cardinality_numberfailure_cardinality_pathfailure_cardinality_numberr   0RuntimeconfigProjectsConfigsWaitersCreateRequest
ConfigPathWaiterRelativeNamer   r+   r
   CreatedResourceasync__async_resourceclientMESSAGES_MODULE-RuntimeconfigProjectsConfigsWaitersGetRequestGetWaitForWaiterIsFailedWaiter	exit_codeFormatWaiter)selfargswaiter_clientmessageswaiter_resourceprojectconfigr,   r-   resultrequests              r#   Run
Create.Rune   s    %%'M}}H**499d;O((G&&F##((..22 ) 
 $ G $$%%**0044 +  & g g!!AA??73??$113dll3	 #  	B 	

F ({{
 -%%55??)668 @ :    )f!d!!/2f			V	$	$V$$r&   c                     U R                   (       ae  [        R                  R                  5         [        R                  R                  SR	                  U R                   R                  5       5      5        gg)zwCalled after resources are displayed if the default format was used.

Args:
  unused_resources_were_displayed: Unused.
zEThe wait command can be used to monitor the progress of waiter [{0}].N)rB   r
   statusPrintr   Name)rK   unused_resources_were_displayeds     r#   EpilogCreate.Epilog   sS     	jj	jj%vd&:&:&?&?&ABD r&   )rB   rI   N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr$   rT   r[   __static_attributes__ r&   r#   r   r      s:      -* )9 )9VD%L
Dr&   r   N)ra   
__future__r   r   r   %googlecloudsdk.api_lib.runtime_configr   googlecloudsdk.callioper   r   )googlecloudsdk.command_lib.runtime_configr	   googlecloudsdk.corer
   CreateCommandr   re   r&   r#   <module>rl      s8     * &  ' 6 / ( ; #XDT XDr&   