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 CreateRequests(self, args): backend_services_ref = self.CreateGlobalReference(args.name) if args.port: port = args.port else: port = 80 if args.port_name: port_name = args.port_name else: port_name = 'http' 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.') request = self.messages.ComputeBackendServicesInsertRequest( backendService=self.messages.BackendService( description=args.description, healthChecks=health_checks, name=backend_services_ref.Name(), port=port, portName=port_name, protocol=protocol, timeoutSec=args.timeout), project=self.project) return [request]
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: port = 80 if args.protocol == 'HTTPS': port = 443 if args.port_name: port_name = args.port_name else: port_name = 'http' if args.protocol == 'HTTPS': port_name = 'https' 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)