
    #                        S r SSKJr  SSK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rSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSr Sr!Sr"Sr#S r$S!r%S"r&S#r'S$r(S%r)S&r* " S' S(\RV                  5      r,g))zBWraps a Serverless Service message, making fields more convenient.    annotationsN)List)
k8s_object)revision)traffic)threat_detection_utilz=us-docker.pkg.dev/serverless-runtimes/google-22/run/universalz!networking.knative.dev/visibilityzcluster-localzrun.googleapis.com/iap-enabledzrun.googleapis.com/ingressz!run.googleapis.com/ingress-statusallinternalz!internal-and-cloud-load-balancingzrun.googleapis.com/minScalezrun.googleapis.com/maxScalez&run.googleapis.com/manualInstanceCountzrun.googleapis.com/scalingModezrun.googleapis.com/operation-idzrun.googleapis.com/presetsz"run.googleapis.com/build-image-urizrun.googleapis.com/build-idz.run.googleapis.com/build-environment-variablesz(run.googleapis.com/build-source-locationz(run.googleapis.com/build-function-targetz$run.googleapis.com/build-worker-poolz(run.googleapis.com/build-service-accountzrun.googleapis.com/build-namez#run.googleapis.com/build-base-imagez1run.googleapis.com/build-enable-automatic-updatesz"run.googleapis.com/source-locationz"run.googleapis.com/function-targetzrun.googleapis.com/image-uriz+run.googleapis.com/enable-automatic-updateszrun.googleapis.com/sourcesc                  N  ^  \ rS rSrSrSrS rU 4S jr\S 5       r	\S 5       r
\S 5       r\S 5       r\S	 5       r\R                  S
 5       r\S 5       r\S 5       r\S 5       rS r\S 5       r\S 5       r\S"S j5       r\S 5       r\R                  S 5       rU 4S jr\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\S  5       r S!r!U =r"$ )#ServiceR   zWraps a Serverless Service message, making fields more convenient.

Setting properties on a Service (where possible) writes through to the
nested Kubernetes-style fields.
zserving.knative.devc                d   > [         TU ]  " U0 UD6  [        R                  R                  U l        g N)super__init__	crtd_utilThreatDetectionStateDISABLEDthreat_detection_state)selfargskwargs	__class__s      )lib/googlecloudsdk/api_lib/run/service.pyr   Service.__init__\   s)    	Gd%f%"+"@"@"I"ID    c                    U R                   R                  [        5      U R                   R                  [        5      U R                   R                  [        5      U R                   R                  [
        5      4$ r   )r   get.RUN_FUNCTIONS_BUILD_SERVICE_ACCOUNT_ANNOTATION*RUN_FUNCTIONS_BUILD_WORKER_POOL_ANNOTATION'RUN_FUNCTIONS_BUILD_ENV_VARS_ANNOTATION(RUN_FUNCTIONS_BUILD_IMAGE_URI_ANNOTATIONr   s    r   run_functions_annotations!Service.run_functions_annotations`   sb     	KLGHDEEF	 r   c                N   U R                   R                  R                  (       d=  [        R                  " U R                  5       5      U R                   R                  l        [        R                  R                  U R                   R                  U R                  5       5      nU$ r   )	spectemplatemetadatar   MakeMetaMessagesModuler   RevisionTemplate)r   rets     r   r)   Service.templatei   sk    99&&$.$7$78K8K8M$Ndii!



$
$TYY%7%79L9L9N
OCJr   c                    U R                  5         [        R                  " U R                  U R                  R
                  5      $ r   )AssertFullObjectr   AnnotationsFromMetadata	_messagesr)   r*   r$   s    r   template_annotationsService.template_annotationsp   s4    --.. r   c                .    U R                   R                  $ r   )r)   labelsr$   s    r   revision_labelsService.revision_labelsw   s    ==r   c                .    U R                   R                  $ r   r)   namer$   s    r   revision_nameService.revision_name{   s    ==r   c                $    XR                   l        g r   r<   r   values     r   r>   r?      s    MMr   c                .    U R                   R                  $ r   )statuslatestCreatedRevisionNamer$   s    r   latest_created_revisionService.latest_created_revision   s    ;;000r   c                .    U R                   R                  $ r   )rD   latestReadyRevisionNamer$   s    r   latest_ready_revisionService.latest_ready_revision   s    ;;...r   c                    U R                   R                   Vs/ s H!  oR                  (       d  M  UR                  PM#     sn$ s  snf r   )rD   r   percentrevisionName)r   ts     r   serving_revisionsService.serving_revisions   s0    $(KK$7$7E$7q99NANN$7EEEs
   AAc                    U R                   R                  =(       a#    UR                  U R                   R                  :H  nUR                  =(       d    U$ )zCReturns True if the target's percent is part of the latest percent.)rD   rI   rN   latestRevision)r   targetis_latest_by_names      r   _ShouldIncludeInLatestPercent%Service._ShouldIncludeInLatestPercent   sH     	++ 	G4;;#F#FF    5$55r   c                V   ^  [        U 4S jT R                  R                   5       5      $ )z<The percent of traffic the latest ready revision is serving.c              3  ~   >#    U  H2  nTR                  U5      (       d  M  UR                  =(       d    S v   M4     g7f)r   N)rV   rM   ).0rT   r   s     r   	<genexpr>1Service.latest_percent_traffic.<locals>.<genexpr>   s4      )F--f5 	!)s   ==)sumrD   r   r$   s   `r   latest_percent_trafficService.latest_percent_traffic   s)      kk))  r   c                    U R                   R                   H:  nU R                  U5      (       d  M  UR                  (       d  M.  UR                  s  $    g)z6A url at which we can reach the latest ready revision.N)rD   r   rV   url)r   rT   s     r   
latest_urlService.latest_url   s@     ++%%		+	+F	3	3


zz & r   c                v    U R                   R                  S5      nU(       d  / $ [        R                  " U5      $ )zList of the Service's URLs.

Returns:
  A list of the URLs present in the Service's run.googleapis.com/urls
  annotation. If this annotation is missing an empty list is returned
  instead.
zrun.googleapis.com/urls)r   r   jsonloads)r   anns     r   urlsService.urls   s1     



8
9Ci::c?r   c                   U R                   nU(       a  US   $ U R                  R                  R                  (       a   U R                  R                  R                  $  U R                  R                  R                  $ ! [
         a     g f = f)Nr   )rh   _mrD   ra   domainAttributeError)r   rh   s     r   rl   Service.domain   si    99D!Wnww~~WW^^WW^^"""  s   A? ?
BBc                    XR                   R                  l         XR                   R                  l        g ! [         a     g f = fr   )rk   rD   ra   rl   rm   )r   rl   s     r   rl   rn      s7    GGNN$ggnn  s   7 
AAc                   > U R                   SL a,  U R                  (       a  U R                  U R                  :w  a  g[        [        U ]  5       $ )NF)!yellow)readyrJ   rF   r   r   ReadySymbolAndColor)r   r   s    r   rt   Service.ReadySymbolAndColor   s?    

e&&((D,F,FF$355r   c                8    U R                   R                  S5      $ )Nz serving.knative.dev/lastModifierr   r   r$   s    r   last_modifierService.last_modifier   s     BCCr   c                    U R                  5         [        R                  " U R                  U R                  R                  5      $ r   )r2   r   TrafficTargetsr4   r(   r$   s    r   spec_trafficService.spec_traffic   s/    !!$..$))2C2CDDr   c                    U R                  5         [        R                  " U R                  U R                  c  / 5      $ U R                  R                  5      $ r   )r2   r   r{   r4   rD   r$   s    r   status_trafficService.status_traffic   sJ    !!dkk1 7;{{7J7J r   c                8    U R                   R                  S5      $ )Nz'run.googleapis.com/vpc-access-connectorrw   r$   s    r   vpc_connectorService.vpc_connector   s     IJJr   c                .    U R                   R                  $ r   r)   imager$   s    r   r   Service.image   s    ==r   c                $    XR                   l        g r   r   rA   s     r   r   r      s    MMr   c                @    U R                   R                  [        5      $ r   )r   r   OPERATION_ID_ANNOTATIONr$   s    r   operation_idService.operation_id   s     788r   c                (    XR                   [        '   g r   )r   r   rA   s     r   r   r      s    05,-r   c                T    U R                   R                  [        R                  5      $ r   )r   r   r   DESCRIPTION_ANNOTATIONr$   s    r   descriptionService.description   s    
 A ABBr   c                     XR                   S'   g )Nzrun.googleapis.com/descriptionr   rA   s     r   r   r      s    9>56r   c                |    U R                   R                  [        U R                   R                  [        5      5      $ )z?Returns the build source location from the service annotations.)r   r   .RUN_FUNCTIONS_BUILD_SOURCE_LOCATION_ANNOTATION3RUN_FUNCTIONS_SOURCE_LOCATION_ANNOTATION_DEPRECATEDr$   s    r   source_locationService.source_location  s7     6?	
 r   c                B    U R                   R                  [        S5      $ )z9Returns the function target from the service annotations.N)r5   r   1SOURCE_DEPLOY_NO_BUILD_SOURCE_LOCATION_ANNOTATIONr$   s    r   *source_deploy_no_build_source_location_map2Service.source_deploy_no_build_source_location_map  s"     $$((94 r   )r   )returnz	List[str])#__name__
__module____qualname____firstlineno____doc__API_CATEGORYKINDr   propertyr%   r)   r5   r9   r>   setterrF   rJ   rP   rV   r^   rb   rh   rl   rt   rx   r|   r   r   r   r   r   r   r   __static_attributes____classcell__)r   s   @r   r   r   R   sP    ',	$J               1 1 / / F F6         
== 6 D D E E   K K   	<<    9 9 6 6 C C ? ?    r   r   )-r   
__future__r   re   typingr   googlecloudsdk.api_lib.runr   r   r   googlecloudsdk.command_lib.runr	   r   DEFAULT_BASE_IMAGEENDPOINT_VISIBILITYCLUSTER_LOCALIAP_ANNOTATIONINGRESS_ANNOTATIONINGRESS_STATUS_ANNOTATIONINGRESS_ALLINGRESS_INTERNAL)INGRESS_INTERNAL_AND_CLOUD_LOAD_BALANCINGSERVICE_MIN_SCALE_ANNOTATIONSERVICE_MAX_SCALE_ANNOTATION MANUAL_INSTANCE_COUNT_ANNOTATIONSERVICE_SCALING_MODE_ANNOTATIONr   PRESETS_ANNOTATIONr#   !RUN_FUNCTIONS_BUILD_ID_ANNOTATIONr"   r   .RUN_FUNCTIONS_BUILD_FUNCTION_TARGET_ANNOTATIONr!   r    #RUN_FUNCTIONS_BUILD_NAME_ANNOTATIONRUN_FUNCTIONS_BUILD_BASE_IMAGE,RUN_FUNCTIONS_BUILD_ENABLE_AUTOMATIC_UPDATESr   3RUN_FUNCTIONS_FUNCTION_TARGET_ANNOTATION_DEPRECATED-RUN_FUNCTIONS_IMAGE_URI_ANNOTATION_DEPRECATED1RUN_FUNCTIONS_ENABLE_AUTOMATIC_UPDATES_DEPRECATEDr   KubernetesObjectr    r   r   <module>r      s   I "   1 / . MT 9 11 ?  ,O )< < #K  "B ; 1 +O ($A !4 ( / / / / + + / / 'F #!F 7 -
 ) 4 ) 4 1O -1 2 5Q 1@j)) @r   