
    }#                       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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+\
R\                  5      r/g),zBWraps a Serverless Service message, making fields more convenient.    )absolute_importannotations)division)unicode_literalsN)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"$ )#ServiceU   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_annotationsc   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.templatel   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_annotationss   s4    --.. r    c                .    U R                   R                  $ r   )r,   labelsr'   s    r   revision_labelsService.revision_labelsz   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   rA   rB      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   )rG   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   )rG   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.)rG   rL   rQ   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)rY   rP   ).0rW   r   s     r   	<genexpr>1Service.latest_percent_traffic.<locals>.<genexpr>   s4      )F--f5 	!)s   ==)sumrG   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)rG   r   rY   url)r   rW   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   )rk   _mrG   rd   domainAttributeError)r   rk   s     r   ro   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   )rn   rG   rd   ro   rp   )r   ro   s     r   ro   rq      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)readyrM   rI   r   r   ReadySymbolAndColor)r   r   s    r   rw   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   )r5   r   TrafficTargetsr7   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   )r5   r   r~   r7   rG   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-connectorrz   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   rD   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   rD   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   rD   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)r8   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,   r8   r<   rA   setterrI   rM   rS   rY   ra   re   rk   ro   rw   r{   r   r   r   r   r   r   r   r   __static_attributes____classcell__)r   s   @r   r   r   U   sP    ',	$J               1 1 / / F F6         
== 6 D D E E   K K   	<<    9 9 6 6 C C ? ?    r    r   )0r   
__future__r   r   r   r   rh   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    