
    $                     ^   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
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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   \
RB                  \
RD                  " \
RF                  RH                  \
RF                  RJ                  5       " S S\
RL                  5      5       5       r'\
RD                  " \
RF                  RP                  5       " S S\'5      5       r)\'R                   \)l         g)z;Command for updating env vars and other configuration info.    )global_methods)service)apis)messages)arg_parsers)base)util)config_changes)connection_context)
exceptions)flags)messages_util)	platforms)pretty_print)resource_args)serverless_operations)stages)concept_parsers)presentation_specs)
properties)	resources)progress_trackerc                   `    \ rS rSrSrSSS.r\S 5       r\S 5       rS r	S	 r
S
 rS rS rSrg)Replace*   z>Create or replace a service from a YAML service specification.zU          Creates or replaces a service from a YAML service specification.
          z          To replace the specification for a service defined in myservice.yaml

              $ {command} myservice.yaml

         )DESCRIPTIONEXAMPLESc           	         [         R                  " S[        R                  " 5       SSSSS9n[        R
                  " U/5      R                  U5        [        R                  " U5        [        R                  " U5        [        R                  " U5        UR                  SS[        R                  " 5       SS	9  UR                  R                  S
5        g )Nz--namespacezNamespace to replace service.TF)requiredprefixeshiddenFILEstoreziThe absolute path to the YAML file with a Knative service definition for the service to update or deploy.)actiontypehelpnone)r   ResourcePresentationSpecr   GetNamespaceResourceSpecr   ConceptParserAddToParserr   AddAsyncFlagAddClientNameAndVersionFlagsAddDryRunFlagadd_argumentr   YAMLFileContentsdisplay_info	AddFormat)clsparsernamespace_presentations      #lib/surface/run/services/replace.py
CommonArgsReplace.CommonArgs=   s     0HH..0' !!#9 #$ %%0[%8 
v	&&v.	
))+B	  C !!&)    c                 &    U R                  U5        g N)r7   r3   r4   s     r6   ArgsReplace.ArgsX   s    NN6r9   c                 |    [         R                  " U[        R                  R                  U R                  5       US9$ )N)region_label)r   GetConnectionContextr   ProductRUNReleaseTrack)selfargsr@   s      r6   _ConnectionContextReplace._ConnectionContext\   s1    22emm!2!2!4< r9   c                 v    [         R                  " U5      [         R                  " U R                  5       5      /$ r;   )r
   ReplaceServiceChangeSetLaunchStageAnnotationChangerD   )rE   new_servicerF   s      r6   _GetBaseChangesReplace._GetBaseChangesa   s3     	++K855d6G6G6IJ r9   c                     g r;    )rE   rF   rL   changess       r6   _GetMultiRegionRegionsReplace._GetMultiRegionRegionsh   s    r9   c                 \   UR                   (       a.  [        R                  " SR                  UR                  S95        g U(       a.  [        R                  " SR                  UR                  S95        g [        R                  " SR                  UR                  UR
                  S95        g )NzPNew configuration for [{{bold}}{serv}{{reset}}] is being applied asynchronously.)servzKNew configuration has been validated for service [{{bold}}{serv}{{reset}}].zdNew configuration has been applied to service [{{bold}}{serv}{{reset}}].
URL: {{bold}}{url}{{reset}})rU   url)async_r   Successformatnamedomain)rE   service_objdry_runrF   s       r6   _PrintSuccessMessageReplace._PrintSuccessMessagek   s    {{"F(8(8F9 
''-v;3C3Cv'D
 ((.##);); )/ )r9   c                    [         R                  " [        R                  [        R                  5      n[        UR                  5      nSU;   a  US	 UR                  S0 5      R                  SS5      nUb&  [        U[        5      (       d  [        U5      US   S'   Sn [        R                  " X2R                  5      n[        R                  " Xb5      nUR"                  R$                  R'                  5       R)                  5       nUR*                  R$                  Gb  UR-                  S5      (       a/  XER*                  R$                  :w  a  [        R.                  " S5      eUR*                  R$                  n[0        R2                  " 5       [0        R4                  :X  a  [6        R8                  R:                  R<                  R?                  5       n[@        RB                  " U5      n	XH:w  a4  U[        U	5      :w  a%  [        R.                  " SRE                  X5      5      eXER*                  l        U RG                  XQ5      n
[H        RJ                  R'                  UR*                  RL                  S	UR*                  R$                  0S
S9nURN                  (       a  URP                  OSnU RS                  X5      n[U        US5      (       a  URV                  OSnU(       a  SOSn[X        RZ                  " U5       nUR]                  U5      nU R_                  XU
5      n[`        Rb                  " [d        Rf                  " XUS95        [h        Rj                  " US9nU(       a  SOSnU(       a  Sn[l        Rn                  " UUSURp                  =(       d    US9 nURs                  UU
U Ru                  5       UURp                  SSUUS9	nSSS5        U Rw                  UX5        UsSSS5        $ ! [        R                   a   n[        R                   " USS9   SnAGNJSnAff = f! , (       d  f       Nb= f! , (       d  f       g= f)z#Create or Update service from YAML.statusmetadata	namespaceNzPlease make sure that the YAML file matches the Knative service definition spec in https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#Service.)	help_textz7Namespace specified in file does not match passed flag.zVNamespace must be project ID [{}] or quoted number [{}] for Cloud Run (fully managed).namespacesIdzrun.namespaces.services)params
collectionr]   Fz Validating new configuration forzApplying new configuration to)	operation)regions_listzDeploying...zDeploying new service...zValidating...zDeployment failed)failure_messagesuppress_outputT)asynallow_unauthenticatedfor_replacer]   multiregion_regions)<r   GetMessagesModuler   SERVERLESS_API_NAMESERVERLESS_API_VERSIONdictr"   get
isinstancestrr   DictToMessageWithErrorCheckServicer   ScalarTypeMismatchErrorr   MaybeRaiseCustomFieldMismatchCONCEPTSrc   ParseNamerb   IsSpecifiedConfigurationErrorr   GetPlatformPLATFORM_MANAGEDr   VALUEScoreprojectGetprojects_utilGetProjectNumberrY   rM   r   REGISTRYrZ   
is_managedregionrG   hasattrr]   r   Connect
GetServicerR   r   Inforun_messages_utilGetStartDeployMessager   ServiceStagesr   StagedProgressTrackerrW   ReleaseServicerD   r^   )rE   rF   run_messagesservice_dictrc   rL   raw_serviceer   project_numberrQ   service_refr@   conn_contextr]   r$   clientr\   regionsdeployment_stagesheadertrackers                         r6   RunReplace.Run   s   ))**--L 		?L
 <
x
    R044[$GIZ	3%?%?.1)nl:{+K
!==
,,.kOOK>k ''--/446I%%1


;
'
'
++55
5++EG 	G&&00i				 I$>$>	>##((00446&77@I^1D$D--++16'+JL L &/""";5G$$**!! 4 4 > >?, + .K
 *5)?)?;%%TL**4>L%dI66dllEG  	+,  
	&	&|	4%%k2k++DwGg

1
16 !..GD"-3Mf	 11

-++0	
 ++"& ' , 

" W;A 
5	4[ 00 ..
 v  
5	4s=    6O1 =BP90P(P91P%P  P%(
P6	2P99
QrP   N)__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr7   r=   rG   rM   rR   r^   r   __static_attributes__rP   r9   r6   r   r   *   s[     G- * *4  
(fr9   r   c                   $    \ rS rSr\S 5       rSrg)AlphaReplace   c                 .    [         R                  U5        g r;   )r   r7   r<   s     r6   r=   AlphaReplace.Args   s    vr9   rP   N)r   r   r   r   r   r=   r   rP   r9   r6   r   r      s      r9   r   N)*r   googlecloudsdk.api_lib.runr   r   googlecloudsdk.api_lib.utilr   r   r   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.projectsr	   r   googlecloudsdk.command_lib.runr
   r   r   r   r   r   r   r   r   r   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   UniverseCompatibleReleaseTracksrD   BETAGACommandr   ALPHAr   rP   r9   r6   <module>r      s    B 6 . , A / ( E 9 = 5 0 M 4 7 8 @ 1 D G * ) 8 D%%**D,=,=,@,@Aydll y B yx D%%++,7  -  r9   