
    #                         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 r
S	 r  SS
 jrSS jrSS jrS rS rSS jrS rS rg)z1Code for making shared messages between commands.    )absolute_import)division)print_function)unicode_literals)
k8s_object)logc                     SR                  U R                  US9nU HI  nSU-   nX@R                  ;   a  U R                  U   R                  S5      OSnUSR                  X5S9-  nMK     U$ )zReturns a user message for a successful synchronous deploy.

Args:
  service: googlecloudsdk.api_lib.run.service.Service, Deployed service for
    which to build a success message.
  regions: list of regions that we deployed to.
zmMulti-Region Service [{{bold}}{s}{{reset}}] has been deployed to regions {{bold}}{r}{{reset}}.
Regional URLs:)srzMultiRegionReady/message z.
{{bold}}{url}{{reset}} ({{bold}}{r}{{reset}}))r   url)formatname
conditionsget)serviceregionsmsgregion	conditionr   s         3lib/googlecloudsdk/command_lib/run/messages_util.py0GetSuccessMessageForMultiRegionSynchronousDeployr      s     F  	  f#f,I *** 	9%)))4 
 <CC
 D  C  
*    c                 P   U R                   R                  nU R                   R                  nU(       a  SOU R                  nSnU(       a  US-  nU R                  nSnU(       a  SR                  U5      nUR                  U R                  U(       a  UOUU R                  US9U-   $ )a  Returns a user message for a successful synchronous deploy.

Args:
  service: googlecloudsdk.api_lib.run.service.Service, Deployed service for
    which to build a success message.
  no_traffic: bool, whether the service was deployed with --no-traffic flag.
r   zService [{{bold}}{serv}{{reset}}] revision [{{bold}}{rev}{{reset}}] has been deployed and is serving {{bold}}{latest_percent_traffic}{{reset}} percent of traffic.z$
Service URL: {{bold}}{url}{{reset}}r   z+
The revision can be reached directly at {})servrevr   latest_percent_traffic)statuslatestReadyRevisionNamelatestCreatedRevisionNamer   
latest_urlr   r   domain)r   
no_trafficlatest_readylatest_createdr   r   r"   tag_url_messages           r   %GetSuccessMessageForSynchronousDeployr(   7   s     77, >>;;. *10N0NF  22C!!*/DKKO 
jj|| *nnn!7	   	r   c           	          SnX@R                   -  nUS:X  a  UR                  OUR                  5       R                  5       nUR	                  UU R
                  UU R                  UR                  5       US9$ )a  Returns a user mesage for starting a deploy.

Args:
  conn_context: connection_context.ConnectionInfo, Metadata for the run API
    client.
  resource_ref: protorpc.messages.Message, A resource reference object for the
    resource. See googlecloudsdk.core.resources.Registry.ParseResourceId for
    details.
  operation: str, what deploy action is being done.
  resource_kind_lower: str, resource kind being deployed, e.g. "service"
zj{operation} {operator} {resource_kind} [{{bold}}{resource}{{reset}}] in {ns_label} [{{bold}}{ns}{{reset}}]zworker pool)	operationoperatorresource_kindns_labelresourcens)location_label
projectsIdParentNamer   r+   r-   )conn_contextresource_refr*   resource_kind_lowerr   r/   s         r   GetStartDeployMessager7   ^   s    $L  	$	$$#
 
	-  %%' 
 
$$'$$  "	 
 
 r   c                     SnUR                  UUR                  5       U R                  UR                  5       R                  5       U R                  S9$ )aj  Returns a user mesage for resource not found.

Args:
  conn_context: connection_context.ConnectionInfo, Metadata for the run API
    client.
  resource_ref: protorpc.messages.Message, A resource reference object for the
    resource. See googlecloudsdk.core.resources.Registry.ParseResourceId for
    details.
  resource_kind: str, resource kind, e.g. "Service"
zW{resource_kind} [{resource}] could not be found in {ns_label} [{ns}] region [{region}].)r,   r.   r-   r/   r   )r   r3   r-   r2   r   )r4   r5   r,   r   s       r   GetNotFoundMessager9      sZ    1 
 
!  "$$					#	#	%   
 
 r   c                     SR                  U(       a  SOSU R                  b  SR                  U R                  5      OSUS9$ )z,Returns a user message for how to run a job.zT
To execute this job{repeat}, use:
gcloud{release_track} run jobs execute {job_name}z againr    {})repeatrelease_trackjob_name)r   prefix)r=   r>   r<   s      r   GetRunJobMessager@      sK    ::@&# %%1 ll=//0 ;A ;r   c                    SR                  U R                  b  SR                  U R                  5      OSUR                  S9nUR                  (       a,  UR                  R                  (       a  US[        U5      -   -  nU$ )zAReturns a user message with execution details when running a job.zr
View details about this execution by running:
gcloud{release_track} run jobs executions describe {execution_name}r;   r   )r=   execution_namez

Or visit )r   r?   r   r   logUri_GetExecutionUiLink)r=   	executionr   s      r   GetExecutionCreatedMessagerF      s{    L
F !!- ,,}++
,^^    )**11?0;;;C	*r   c                 `    SR                  U R                  U R                  U R                  S9$ )Nzhhttps://console.cloud.google.com/run/jobs/executions/details/{region}/{execution_name}?project={project})r   rB   project)r   r   r   	namespace)rE   s    r   rD   rD      s4    <
F^^!!  r   c                 <    U(       a  SOSnSnUR                  XX#S9$ )ag  Returns a user message for equivalent gcloud commands for source deploy.

Args:
  name: name of the source target, which is either a service, a job or a
    worker
  pack: the pack arguments used to build the container image
  source: the location of the source
  subgroup: subgroup name for this command. Either 'jobs ', 'workers ' or
    empty for services
z--pack image=[IMAGE]z--tag [IMAGE]zThis command is equivalent to running `gcloud builds submit {build_flag} {source}` and `gcloud run {subgroup}deploy {name} --image [IMAGE]`
)r   
build_flagsourcesubgroup)r   )r   packrL   rM   rK   r   s         r   %GetBuildEquivalentForSourceRunMessagerO      s5     *.%?*? 
 
v 
 
 r   c                 X   SU ;   =(       a    U R                   nSU ;   =(       a    U R                  nSU ;   aQ  U R                  (       a@  U R                  R                  5        H"  u  pESU;   d  M  UR                   (       d  M   SnM$     U=(       ac    UR                  =(       aP    UR                  R
                  =(       a3    UR                  R
                  R                  [        R                  5      nU(       a0  U(       d(  U(       d   [        R                  R                  S5        ggggzELogs a user message for GPU type default value if it is not provided.gpugpu_type
containersTzYNo GPU type is provided, defaulting to nvidia-l4. To specify the GPU type use --gpu-type.N)rR   rS   rT   itemstemplatenode_selectorr   r   GPU_TYPE_NODE_SELECTORr   r   Printargsr.   gpu_setgpu_type_set_container_argshas_gpu_types          r   MaybeLogDefaultGpuTypeMessagera      s    TM&dhh't#5,Tdoo!__224	.	 ^%7%7%7 5  Q


Q



)
)Q 


)
)
-
-j.O.O
P	  \,JJ	$ +7\Wr   c                 2   SU ;   =(       a    U R                   nSU ;   =(       a    U R                  nSU ;   aQ  U R                  (       a@  U R                  R                  5        H"  u  pESU;   d  M  UR                   (       d  M   SnM$     U=(       aP    UR                  =(       a=    UR                  R
                  =(       a     UR                  R
                  R                  nU(       a0  U(       d(  U(       d   [        R                  R                  S5        ggggrQ   )
rR   rS   rT   rU   rV   rW   acceleratorr   r   rY   rZ   s          r   *MaybeLogDefaultGpuTypeMessageForV2Resourcerd      s    TM&dhh't#5,Tdoo!__224	.	 ^%7%7%7 5  6


6



)
)6 


)
)
5
5	  \,JJ	$ +7\Wr   N)zDeploying container tor   )Service)F)r   )__doc__
__future__r   r   r   r   googlecloudsdk.api_lib.runr   googlecloudsdk.corer   r   r(   r7   r9   r@   rF   rD   rO   ra   rd    r   r   <module>rk      sX    8 &  % ' 1 #:$T '!	$N2 $,*r   