
                             d 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mZ ddlmZ ddlZ G d dej(                        Z G d de
j,                        Zy)zThe Start command.    )absolute_import)division)unicode_literals)appengine_api_client)operations_util)version_util)base)
exceptions)log)
console_io)progress_tracker)resource_printerNc                       e Zd ZdZy)VersionsStartErrorz(Errors occurring when starting versions.N)__name__
__module____qualname____doc__     !lib/surface/app/versions/start.pyr   r   "   s    0r   r   c                   .    e Zd ZdZddiZed        Zd Zy)StartzStart serving specified versions.

  This command starts serving the specified versions. It may only be used if the
  scaling module for your service has been set to manual.
  EXAMPLESa            To start a specific version across all services, run:

            $ {command} v1

          To start multiple named versions across all services, run:

            $ {command} v1 v2

          To start a single version on a single service, run:

            $ {command} --service=servicename v1

          To start multiple versions in a single service, run:

            $ {command} --service=servicename v1 v2
          c                 T    | j                  ddd       | j                  ddd       y )	Nversions+zCThe versions to start. (optionally filtered by the --service flag).)nargshelpz	--servicez-sz9If specified, only start versions from the given service.)r   )add_argument)parsers    r   Argsz
Start.ArgsB   s9    

#M  P
T/  1r   c           
         t        j                  | j                               }|j                         }t	        j
                  |j                  |      |j                  |j                        }|st        j                  d       y d}t        j                  ||t        j                         t        j                  d       i }t!        |t"              D ]e  }	 t%        j&                  dj)                  |            5  t+        j,                  |j.                  |j                  |j0                         d d d        g |ri }	|j9                         D ]@  \  }}
dj)                  |j                  |j0                        }d	j)                  ||
      |	|<   B t;        d
j)                  dj=                  t?        |	jA                                           dj=                  t?        |	jC                                     z         y # 1 sw Y   xY w# t*        j2                  $ r#}t5        j6                  |      ||<   Y d }~fd }~ww xY w)NzNo matching versions found.z.list[title="Starting the following versions:"])outT)cancel_on_no)keyzStarting [{0}]z	[{0}/{1}]z{0}: {1}z!Issues starting version(s): {0}

z, z

)"r   GetApiClientForTrackReleaseTrackListServicesr   GetMatchingVersionsListVersionsr   servicer   warningr   Printstatusr   PromptContinuesortedstrr   ProgressTrackerformatr   CallAndCollectOpErrorsStartVersionidMiscOperationErrorsix	text_typeitemsr   joinlistkeysvalues)selfargs
api_clientservicesr   fmterrorsversionerrprintable_errors	error_msg
short_names               r   Runz	Start.RunJ   s    &::4;L;L;NOJ&&(H//)t||%H 	kk/0
:C8Scjj940F(,---.>.E.Eg.NO

0
0%%w

D P -  &
'9 ''D
'1'8'8Y'O$ !/ 
/
6
6ii-224568
++d+2245
678 8  PO // ---,w-s0   $H?6H 5H H		HIH==IN)r   r   r   r   detailed_helpstaticmethodr"   rK   r   r   r   r   r   '   s1      -( 1 1#8r   r   )r   
__future__r   r   r   googlecloudsdk.api_lib.appr   r   r   googlecloudsdk.callioper	   googlecloudsdk.corer
   r   googlecloudsdk.core.consoler   r   googlecloudsdk.core.resourcer   r9   Errorr   Commandr   r   r   r   <module>rV      sU      &  ' ; 6 3 ( * # 2 8 9 
)) 
F8DLL F8r   