
                         R   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  SSKJ r   SSK!J"r"   " S S\RF                  5      r$g)z;Command for updating env vars and other configuration info.    )absolute_import)division)print_function)unicode_literals)global_methods)job)apis)messages)arg_parsers)base)util)config_changes)connection_context)
exceptions)flags)messages_util)pretty_print)serverless_operations)stages)config)log)
properties)	resources)progress_trackerc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Replace,   z6Create or replace a job from a YAML job specification.zM          Creates or replaces a job from a YAML job specification.
          zw          To replace the specification for a job defined in myjob.yaml

              $ {command} myjob.yaml

         )DESCRIPTIONEXAMPLESc                     [         R                  " U 5        [         R                  " U 5        U R                  SS[        R
                  " 5       SS9  U R                  R                  S5        g )NFILEstorezcThe absolute path to the YAML file with a Cloud Run job definition for the job to update or create.)actiontypehelpnone)r   AddAsyncFlagAddClientNameAndVersionFlagsadd_argumentr   YAMLFileContentsdisplay_info	AddFormat)parsers    lib/surface/run/jobs/replace.pyArgsReplace.Args=   s^    	v	&&v.
))+:	  ; !!&)    c           	      b
   [         R                  " [        R                  [        R                  5      n[        UR                  5      nSU;   a  US	 SU;  d	  SUS   ;  a  [        R                  " S5      eSUS   S   ;  a  0 US   S   S'   UR                  S0 5      R                  SS5      nUb&  [        U[        5      (       d  [        U5      US   S'    [        R                  " X2R                  5      n[        R                  " XR5      n[$        R&                  R(                  R*                  R-                  5       nWR.                  R0                  bg  Un[2        R4                  " U5      n	UR.                  R0                  nXH:w  a4  U[        U	5      :w  a%  [        R                  " S
R7                  X5      5      eXFR.                  l        UR9                  S5      =(       d    UR9                  S5      n
[:        R<                  " U5      [:        R>                  " U RA                  5       5      [:        RB                  " U
(       a  URD                  OSU
(       a  URF                  O[H        RJ                  SS9/n[L        RN                  RQ                  UR.                  RR                  SUR.                  R0                  0SS9nURT                  (       a  URV                  OSn[X        RZ                  " U[\        R^                  R`                  U RA                  5       US9n[b        Rd                  " U5       nURg                  U5      nU(       + nU(       a  SOSn[h        Rj                  " [l        Rn                  " XUS5      5        US-   n[p        Rr                  " U[t        Rv                  " 5       SURx                  S9 nU(       a  UR{                  XUURx                  S9nOUR}                  XUURx                  S9nSSS5        U(       a  SOSnURx                  (       a/  [h        R~                  " SR7                  URR                  US95        O.[h        R~                  " SR7                  URR                  US95        [        R                  R                  [l        R                  " U RA                  5       URR                  5      5        UsSSS5        $ ! [        R                    a   n[        R"                  " USS	9   SnAGNSnAff = f! , (       d  f       GN= f! , (       d  f       g= f) zCreate or Update job from YAML.statusspectemplatezRspec.template is required but missing. Please check the content in your yaml file.metadata	namespaceNzPlease make sure that the YAML file matches the Cloud Run job definition spec in https://cloud.google.com/run/docs/reference/rest/v1/namespaces.jobs#Job)	help_textzVNamespace must be project ID [{}] or quoted number [{}] for Cloud Run (fully managed).client_nameclient_versiongcloudT)set_on_templatenamespacesIdzrun.namespaces.jobs)params
collection)region_labelCreatingUpdatingr   z job...zJob failed to deploy)failure_messagesuppress_output)asyncreatedupdatedzAJob [{{bold}}{job}{{reset}}] is being {operation} asynchronously.)r   	operationz?Job [{{bold}}{job}{{reset}}] has been successfully {operation}.)Dr	   GetMessagesModuler   SERVERLESS_API_NAMESERVERLESS_API_VERSIONdictr!   r   ConfigurationErrorget
isinstancestrr   DictToMessageWithErrorCheckJobr   ScalarTypeMismatchErrorMaybeRaiseCustomFieldMismatchr   VALUEScoreprojectGetr6   r7   projects_utilGetProjectNumberformatIsSpecifiedr   ReplaceJobChangeSetLaunchStageAnnotationChangeReleaseTrack'SetClientNameAndVersionAnnotationChanger9   r:   r   CLOUD_SDK_VERSIONr   REGISTRYParsename
is_managedregionr   GetConnectionContextr   ProductRUNr   ConnectGetJobr   Inforun_messages_utilGetStartDeployMessager   StagedProgressTrackerr   	JobStagesasync_	UpdateJob	CreateJobSuccessr   r3   PrintGetRunJobMessage)selfargsrun_messagesjob_dictr7   raw_jobnew_joberW   project_numberis_either_specifiedchangesjob_refr@   conn_contextclientjob_obj	is_createrH   headertrackers                        r.   RunReplace.RunJ   sy   )).*L*L*8*O*OQLDIIH 8
8
h*HV4D"D))89 9
 &)*5513hvz":. Z,00dCIZ	3%?%?*-i.hz;'	*99
$$&g.g !!&&..224I!!-g$55i@n"",,i		)s>/B"B++))/)HJ 	J "+ 	'M4+;+;<L+M  	''055d6G6G6IJ>> 3D" (.(@(@ 		"G   && 0 0 : :;( ' *G
 &-%7%77>>TL%::emm!2!2!4<QL 
	&	&|	4g&g+i!*:
i

1
1,2;UDE 9$f11




1++	' +2$$dkk % ;' $$dkk % ;'' !*9yi	$ffK	M 	 99?%,\\Y :@ :H	I 
jj

,
,T->->-@',,
OQC 
5	4S 00 *..
)* **f' ' 
5	4s>   6S 7B	T  ?T?CT T+TT
T	T  
T. N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr/   r   __static_attributes__r   r1   r.   r   r   ,   s0    >- 
* 
*fr1   r   N)%r   
__future__r   r   r   r   googlecloudsdk.api_lib.runr   r   googlecloudsdk.api_lib.utilr	   r
   r   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.projectsr   rY   googlecloudsdk.command_lib.runr   r   r   r   rm   r   r   r   googlecloudsdk.corer   r   r   r   googlecloudsdk.core.consoler   Commandr   r   r1   r.   <module>r      se    B &  % ' 5 * , A / ( E 9 = 5 0 M 7 @ 1 & # * ) 8Ddll Dr1   