def Modify(self, args, existing): replacement = copy.deepcopy(existing) if args.description: replacement.description = args.description elif args.description is not None: replacement.description = None health_checks = backend_services_utils.GetHealthChecks(args, self) if health_checks: replacement.healthChecks = health_checks if args.timeout: replacement.timeoutSec = args.timeout if args.port: replacement.port = args.port if args.port_name: replacement.portName = args.port_name if args.protocol: replacement.protocol = (self.messages.BackendService .ProtocolValueValuesEnum(args.protocol)) return replacement
def _CreateRegionBackendService(self, args): health_checks = backend_services_utils.GetHealthChecks(args, self) if not health_checks: raise exceptions.ToolException( 'At least one health check required.') return self.messages.BackendService( description=args.description, name=args.name, healthChecks=health_checks, loadBalancingScheme=(self.messages.BackendService. LoadBalancingSchemeValueValuesEnum( args.load_balancing_scheme)), protocol=_ResolveProtocol(self.messages, args, default='TCP'), timeoutSec=args.timeout)
def _CreateBackendService(self, args): backend_services_ref = self.CreateGlobalReference(args.name) health_checks = backend_services_utils.GetHealthChecks(args, self) if not health_checks: raise exceptions.ToolException( 'At least one health check required.') return self.messages.BackendService(description=args.description, name=backend_services_ref.Name(), healthChecks=health_checks, port=_ResolvePort(args), portName=_ResolvePortName(args), protocol=_ResolveProtocol( self.messages, args), timeoutSec=args.timeout)
def _CommonBackendServiceKwargs(self, args): """Prepare BackendService kwargs for fields common to all release tracks. Args: args: CLI args to translate to BackendService proto kwargs. Returns: A dictionary of keyword arguments to be passed to the BackendService proto constructor. """ backend_services_ref = self.CreateGlobalReference(args.name) if args.port: port = args.port else: # Default to port 80, which is used for HTTP and TCP. port = 80 if args.protocol in ['HTTPS', 'SSL']: port = 443 if args.port_name: port_name = args.port_name else: # args.protocol == 'HTTP' port_name = 'http' if args.protocol == 'HTTPS': port_name = 'https' elif args.protocol == 'SSL': port_name = 'ssl' elif args.protocol == 'TCP': port_name = 'tcp' protocol = self.messages.BackendService.ProtocolValueValuesEnum( args.protocol) health_checks = backend_services_utils.GetHealthChecks(args, self) if not health_checks: raise exceptions.ToolException( 'At least one health check required.') return dict(description=args.description, healthChecks=health_checks, name=backend_services_ref.Name(), port=port, portName=port_name, protocol=protocol, timeoutSec=args.timeout)
def _CreateBackendService(self, args, backend_services_ref): health_checks = backend_services_utils.GetHealthChecks(args, self) if not health_checks: raise exceptions.ToolException( 'At least one health check required.') enable_cdn = True if args.enable_cdn else None return self.messages.BackendService(description=args.description, name=backend_services_ref.Name(), healthChecks=health_checks, port=_ResolvePort(args), portName=_ResolvePortName(args), protocol=_ResolveProtocol( self.messages, args), timeoutSec=args.timeout, enableCDN=enable_cdn)
def Modify(self, args, existing): replacement = copy.deepcopy(existing) if args.connection_draining_timeout is not None: replacement.connectionDraining = self.messages.ConnectionDraining( drainingTimeoutSec=args.connection_draining_timeout) if args.description: replacement.description = args.description elif args.description is not None: replacement.description = None health_checks = backend_services_utils.GetHealthChecks(args, self) if health_checks: replacement.healthChecks = health_checks if args.timeout: replacement.timeoutSec = args.timeout if args.port: replacement.port = args.port if args.port_name: replacement.portName = args.port_name if args.protocol: replacement.protocol = ( self.messages.BackendService.ProtocolValueValuesEnum( args.protocol)) if args.enable_cdn is not None: replacement.enableCDN = args.enable_cdn if args.session_affinity is not None: replacement.sessionAffinity = ( self.messages.BackendService.SessionAffinityValueValuesEnum( args.session_affinity)) if args.affinity_cookie_ttl is not None: replacement.affinityCookieTtlSec = args.affinity_cookie_ttl return replacement