def _CreateRegionalRequests(self, client, resources, args, forwarding_rule_ref): """Create a regionally scoped request.""" target_ref, region_ref = utils.GetRegionalTarget(client, resources, args, forwarding_rule_ref, include_alpha=True) if not args.region and region_ref: args.region = region_ref protocol = self.ConstructProtocol(client.messages, args) network_tier = self.ConstructNetworkTier(client.messages, args) address = self._ResolveAddress( resources, args, compute_flags.compute_scope.ScopeEnum.REGION, forwarding_rule_ref) forwarding_rule = client.messages.ForwardingRule( description=args.description, name=forwarding_rule_ref.Name(), IPAddress=address, IPProtocol=protocol, networkTier=network_tier, loadBalancingScheme=_GetLoadBalancingScheme(args, client.messages)) if (target_ref.Collection() == 'compute.regionBackendServices') or ( target_ref.Collection() == 'compute.targetInstances' and args.load_balancing_scheme == 'INTERNAL'): forwarding_rule.portRange = args.port_range if target_ref.Collection() == 'compute.regionBackendServices': forwarding_rule.backendService = target_ref.SelfLink() else: forwarding_rule.target = target_ref.SelfLink() if args.ports: forwarding_rule.portRange = None forwarding_rule.ports = [ str(p) for p in _GetPortList(args.ports) ] if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NETWORK_ARG.ResolveAsResource( args, resources).SelfLink() else: forwarding_rule.portRange = (_ResolvePortRange( args.port_range, args.ports)) forwarding_rule.target = target_ref.SelfLink() if hasattr(args, 'service_label'): forwarding_rule.serviceLabel = args.service_label request = client.messages.ComputeForwardingRulesInsertRequest( forwardingRule=forwarding_rule, project=forwarding_rule_ref.project, region=forwarding_rule_ref.region) return [(client.apitools_client.forwardingRules, 'Insert', request)]
def CreateRegionalRequests(self, client, resources, forwarding_rule_ref, args): """Create a regionally scoped request.""" target_ref, _ = utils.GetRegionalTarget( client, resources, args, forwarding_rule_ref=forwarding_rule_ref) request = client.messages.ComputeForwardingRulesSetTargetRequest( forwardingRule=forwarding_rule_ref.Name(), project=forwarding_rule_ref.project, region=forwarding_rule_ref.region, targetReference=client.messages.TargetReference( target=target_ref.SelfLink(), ), ) return [(client.apitools_client.forwardingRules, 'SetTarget', request)]
def _CreateRegionalRequests(self, client, resources, args, forwarding_rule_ref): """Create a regionally scoped request.""" target_ref, region_ref = utils.GetRegionalTarget( client, resources, args, forwarding_rule_ref, include_l7_internal_load_balancing=self. _support_l7_internal_load_balancing) if not args.region and region_ref: args.region = region_ref protocol = self.ConstructProtocol(client.messages, args) address = self._ResolveAddress( resources, args, compute_flags.compute_scope.ScopeEnum.REGION, forwarding_rule_ref) forwarding_rule = client.messages.ForwardingRule( description=args.description, name=forwarding_rule_ref.Name(), IPAddress=address, IPProtocol=protocol, networkTier=_ConstructNetworkTier(client.messages, args), loadBalancingScheme=_GetLoadBalancingScheme(args, client.messages)) ports_all_specified, range_list = _ExtractPortsAndAll(args.ports) if (target_ref.Collection() == 'compute.regionBackendServices') or ( target_ref.Collection() == 'compute.targetInstances' and args.load_balancing_scheme == 'INTERNAL'): forwarding_rule.portRange = (six.text_type(args.port_range) if args.port_range else None) if target_ref.Collection() == 'compute.regionBackendServices': forwarding_rule.backendService = target_ref.SelfLink() else: forwarding_rule.target = target_ref.SelfLink() if ports_all_specified: forwarding_rule.allPorts = True if range_list: forwarding_rule.portRange = None forwarding_rule.ports = [ six.text_type(p) for p in _GetPortList(range_list) ] if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing ).ResolveAsResource(args, resources).SelfLink() elif ( (target_ref.Collection() == 'compute.regionTargetHttpProxies' or target_ref.Collection() == 'compute.regionTargetHttpsProxies') and args.load_balancing_scheme == 'INTERNAL'): forwarding_rule.ports = [ six.text_type(p) for p in _GetPortList(range_list) ] if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing ).ResolveAsResource(args, resources).SelfLink() forwarding_rule.target = target_ref.SelfLink() elif args.load_balancing_scheme == 'INTERNAL': raise exceptions.InvalidArgumentException( '--load-balancing-scheme', 'Only target instances and backend services should be specified as ' 'a target for internal load balancing.') elif args.load_balancing_scheme == 'INTERNAL_MANAGED': forwarding_rule.portRange = (_ResolvePortRange( args.port_range, range_list)) if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing ).ResolveAsResource(args, resources).SelfLink() forwarding_rule.target = target_ref.SelfLink() else: forwarding_rule.portRange = (_ResolvePortRange( args.port_range, range_list)) forwarding_rule.target = target_ref.SelfLink() if hasattr(args, 'service_label'): forwarding_rule.serviceLabel = args.service_label if self._support_global_access and args.IsSpecified( 'allow_global_access'): forwarding_rule.allowGlobalAccess = args.allow_global_access if hasattr(args, 'is_mirroring_collector'): forwarding_rule.isMirroringCollector = args.is_mirroring_collector request = client.messages.ComputeForwardingRulesInsertRequest( forwardingRule=forwarding_rule, project=forwarding_rule_ref.project, region=forwarding_rule_ref.region) return [(client.apitools_client.forwardingRules, 'Insert', request)]
def _CreateRegionalRequests(self, client, resources, args, forwarding_rule_ref, supports_network_tier=False, validate_beta_args=False): """Create a regionally scoped request.""" target_ref, region_ref = utils.GetRegionalTarget( client, resources, args, forwarding_rule_ref, allow_global_target=validate_beta_args, include_alpha=(self.ReleaseTrack() == base.ReleaseTrack.ALPHA)) if not args.region and region_ref: args.region = region_ref protocol = self.ConstructProtocol(client.messages, args) address = self._ResolveAddress( resources, args, compute_flags.compute_scope.ScopeEnum.REGION, forwarding_rule_ref) forwarding_rule = client.messages.ForwardingRule( description=args.description, name=forwarding_rule_ref.Name(), IPAddress=address, IPProtocol=protocol, loadBalancingScheme=_GetLoadBalancingScheme(args, client.messages)) if supports_network_tier: network_tier = self.ConstructNetworkTier(client.messages, args) forwarding_rule.networkTier = network_tier ports_all_specified, range_list = _ExtractPortsAndAll(args.ports) if (target_ref.Collection() == 'compute.regionBackendServices') or ( target_ref.Collection() == 'compute.targetInstances' and args.load_balancing_scheme == 'INTERNAL'): forwarding_rule.portRange = (str(args.port_range) if args.port_range else None) if target_ref.Collection() == 'compute.regionBackendServices': forwarding_rule.backendService = target_ref.SelfLink() else: forwarding_rule.target = target_ref.SelfLink() if ports_all_specified: forwarding_rule.allPorts = True if range_list: forwarding_rule.portRange = None forwarding_rule.ports = [ str(p) for p in _GetPortList(range_list) ] if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NETWORK_ARG.ResolveAsResource( args, resources).SelfLink() else: if (forwarding_rule_ref.Collection() == 'compute.forwardingRules' and target_ref.Collection() == 'compute.regionTargetHttpProxies' and args.load_balancing_scheme == 'INTERNAL'): forwarding_rule.ports = [ str(p) for p in _GetPortList(range_list) ] if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NETWORK_ARG.ResolveAsResource( args, resources).SelfLink() else: forwarding_rule.portRange = (_ResolvePortRange( args.port_range, range_list)) forwarding_rule.target = target_ref.SelfLink() if hasattr(args, 'service_label'): forwarding_rule.serviceLabel = args.service_label request = client.messages.ComputeForwardingRulesInsertRequest( forwardingRule=forwarding_rule, project=forwarding_rule_ref.project, region=forwarding_rule_ref.region) return [(client.apitools_client.forwardingRules, 'Insert', request)]
def _CreateRegionalRequests(self, client, resources, args, forwarding_rule_ref): """Create a regionally scoped request.""" is_psc_ilb = False if hasattr(args, 'target_service_attachment' ) and args.target_service_attachment: if not self._support_target_service_attachment: raise exceptions.InvalidArgumentException( '--target-service-attachment', 'Private Service Connect for ILB (the target-service-attachment ' 'option) is not supported in this API version.') else: is_psc_ilb = True target_ref, region_ref = utils.GetRegionalTarget( client, resources, args, forwarding_rule_ref, include_l7_internal_load_balancing=self. _support_l7_internal_load_balancing, include_target_service_attachment=self. _support_target_service_attachment) if not args.region and region_ref: args.region = region_ref protocol = self.ConstructProtocol(client.messages, args) address = self._ResolveAddress( resources, args, compute_flags.compute_scope.ScopeEnum.REGION, forwarding_rule_ref) load_balancing_scheme = _GetLoadBalancingScheme( args, client.messages, is_psc_ilb) if is_psc_ilb and load_balancing_scheme: raise exceptions.InvalidArgumentException( '--load-balancing-scheme', 'The --load-balancing-scheme flag is not allowed for PSC-ILB ' 'forwarding rules.') if args.ip_version: ip_version = client.messages.ForwardingRule.IpVersionValueValuesEnum( args.ip_version) else: ip_version = None forwarding_rule = client.messages.ForwardingRule( description=args.description, name=forwarding_rule_ref.Name(), IPAddress=address, IPProtocol=protocol, networkTier=_ConstructNetworkTier(client.messages, args), loadBalancingScheme=load_balancing_scheme) if ip_version: forwarding_rule.ipVersion = ip_version ports_all_specified, range_list = _ExtractPortsAndAll(args.ports) if target_ref.Collection() == 'compute.serviceAttachments': forwarding_rule.target = target_ref.SelfLink() if args.network is not None: forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing ).ResolveAsResource(args, resources).SelfLink() elif (target_ref.Collection() == 'compute.regionBackendServices') or ( target_ref.Collection() == 'compute.targetInstances' and args.load_balancing_scheme == 'INTERNAL'): forwarding_rule.portRange = (six.text_type(args.port_range) if args.port_range else None) if target_ref.Collection() == 'compute.regionBackendServices': forwarding_rule.backendService = target_ref.SelfLink() else: forwarding_rule.target = target_ref.SelfLink() if ports_all_specified: forwarding_rule.allPorts = True if range_list: forwarding_rule.portRange = None forwarding_rule.ports = [ six.text_type(p) for p in _GetPortList(range_list) ] if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing ).ResolveAsResource(args, resources).SelfLink() elif ( (target_ref.Collection() == 'compute.regionTargetHttpProxies' or target_ref.Collection() == 'compute.regionTargetHttpsProxies') and args.load_balancing_scheme == 'INTERNAL'): forwarding_rule.ports = [ six.text_type(p) for p in _GetPortList(range_list) ] if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing ).ResolveAsResource(args, resources).SelfLink() forwarding_rule.target = target_ref.SelfLink() elif args.load_balancing_scheme == 'INTERNAL': raise exceptions.InvalidArgumentException( '--load-balancing-scheme', 'Only target instances and backend services should be specified as ' 'a target for internal load balancing.') elif args.load_balancing_scheme == 'INTERNAL_MANAGED': forwarding_rule.portRange = (_ResolvePortRange( args.port_range, range_list)) if args.subnet is not None: if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing ).ResolveAsResource(args, resources).SelfLink() forwarding_rule.target = target_ref.SelfLink() else: forwarding_rule.portRange = (_ResolvePortRange( args.port_range, range_list)) forwarding_rule.target = target_ref.SelfLink() if hasattr(args, 'service_label'): forwarding_rule.serviceLabel = args.service_label if self._support_global_access and args.IsSpecified( 'allow_global_access'): forwarding_rule.allowGlobalAccess = args.allow_global_access if hasattr(args, 'is_mirroring_collector'): forwarding_rule.isMirroringCollector = args.is_mirroring_collector if hasattr(args, 'service_directory_registration' ) and args.service_directory_registration: # Parse projects/../locations/../namespaces/../services/.. match = re.match( r'^projects/([^/]+)/locations/([^/]+)/namespaces/([^/]+)/services/([^/]+)$', args.service_directory_registration) if not match: raise exceptions.InvalidArgumentException( '--service-directory-registration', 'Must be of the form projects/PROJECT/locations/REGION/namespace/NAMESPACE/services/SERVICE' ) project = match.group(1) region = match.group(2) if project != forwarding_rule_ref.project or region != forwarding_rule_ref.region: raise exceptions.InvalidArgumentException( '--service-directory-registration', 'Service Directory registration must be in the same project and region as the forwarding rule.' ) sd_registration = client.messages.ForwardingRuleServiceDirectoryRegistration( namespace=match.group(3), service=match.group(4)) forwarding_rule.serviceDirectoryRegistrations.append( sd_registration) request = client.messages.ComputeForwardingRulesInsertRequest( forwardingRule=forwarding_rule, project=forwarding_rule_ref.project, region=forwarding_rule_ref.region) return [(client.apitools_client.forwardingRules, 'Insert', request)]
def _CreateRegionalRequests(self, client, resources, args, forwarding_rule_ref): """Create a regionally scoped request.""" is_psc_ilb = False if hasattr(args, 'target_service_attachment') and args.target_service_attachment: if not self._support_target_service_attachment: raise exceptions.InvalidArgumentException( '--target-service-attachment', 'Private Service Connect for ILB (the target-service-attachment ' 'option) is not supported in this API version.') else: is_psc_ilb = True target_ref, region_ref = utils.GetRegionalTarget( client, resources, args, forwarding_rule_ref, include_regional_tcp_proxy=self._support_regional_tcp_proxy, include_l7_internal_load_balancing=self ._support_l7_internal_load_balancing, include_target_service_attachment=self ._support_target_service_attachment) if not args.region and region_ref: args.region = region_ref protocol = self.ConstructProtocol(client.messages, args) address = self._ResolveAddress(resources, args, compute_flags.compute_scope.ScopeEnum.REGION, forwarding_rule_ref) load_balancing_scheme = _GetLoadBalancingScheme(args, client.messages, is_psc_ilb) if is_psc_ilb and load_balancing_scheme: raise exceptions.InvalidArgumentException( '--load-balancing-scheme', 'The --load-balancing-scheme flag is not allowed for PSC-ILB ' 'forwarding rules.') if args.ip_version: ip_version = client.messages.ForwardingRule.IpVersionValueValuesEnum( args.ip_version) else: ip_version = None forwarding_rule = client.messages.ForwardingRule( description=args.description, name=forwarding_rule_ref.Name(), IPAddress=address, IPProtocol=protocol, networkTier=_ConstructNetworkTier(client.messages, args), loadBalancingScheme=load_balancing_scheme) if ip_version: forwarding_rule.ipVersion = ip_version if self._support_source_ip_range and args.source_ip_ranges: forwarding_rule.sourceIpRanges = args.source_ip_ranges if args.subnet is not None: # Subnet arg needed for: # - L4ILB and internal protocol forwarding (scheme INTERNAL, target BES # or target instance) # - L7ILB (scheme INTERNAL_MANAGED) # - NetLB or external protocol forwarding when using IPv6 (scheme # EXTERNAL target BES or target instance) if not args.subnet_region: args.subnet_region = forwarding_rule_ref.region forwarding_rule.subnetwork = flags.SUBNET_ARG.ResolveAsResource( args, resources).SelfLink() if args.network is not None: # Network arg needed for: # - L4ILB and internal protocol forwarding (scheme INTERNAL, target BES # or target instance) # - L7ILB (scheme INTERNAL_MANAGED) # - PSC forwarding rules (no scheme) forwarding_rule.network = flags.NetworkArg( self._support_l7_internal_load_balancing).ResolveAsResource( args, resources).SelfLink() ports_all_specified, range_list = _ExtractPortsAndAll(args.ports) if target_ref.Collection() == 'compute.regionBackendServices': # A FR pointing to a BES has no target attribute. forwarding_rule.backendService = target_ref.SelfLink() forwarding_rule.target = None else: # A FR pointing to anything not a BES has a target attribute. forwarding_rule.backendService = None forwarding_rule.target = target_ref.SelfLink() if ((target_ref.Collection() == 'compute.regionBackendServices' or target_ref.Collection() == 'compute.targetInstances') and args.load_balancing_scheme == 'INTERNAL'): # This is for L4ILB and internal protocol forwarding. # API fields allPorts, ports, and portRange are mutually exclusive. # API field portRange is not valid for this case. # Use of L3_DEFAULT implies all ports even if allPorts is unset. if ports_all_specified: forwarding_rule.allPorts = True elif range_list: forwarding_rule.ports = [ six.text_type(p) for p in _GetPortList(range_list) ] elif ((target_ref.Collection() == 'compute.regionTargetHttpProxies' or target_ref.Collection() == 'compute.regionTargetHttpsProxies') and args.load_balancing_scheme == 'INTERNAL'): # This is a legacy configuration for L7ILB. forwarding_rule.ports = [ six.text_type(p) for p in _GetPortList(range_list) ] elif args.load_balancing_scheme == 'INTERNAL': # There are currently no other valid combinations of targets with scheme # internal. With scheme internal, targets must presently be a regional # backend service (L4ILB) or a target instance (protocol forwarding). raise exceptions.InvalidArgumentException( '--load-balancing-scheme', 'Only target instances and backend services should be specified as ' 'a target for internal load balancing.') elif args.load_balancing_scheme == 'INTERNAL_MANAGED': # This is L7ILB. forwarding_rule.portRange = _MakeSingleUnifiedPortRange( args.port_range, range_list) elif args.load_balancing_scheme == 'EXTERNAL_MANAGED': # This is regional L7XLB. forwarding_rule.portRange = _MakeSingleUnifiedPortRange( args.port_range, range_list) elif ((target_ref.Collection() == 'compute.regionBackendServices') and ((args.load_balancing_scheme == 'EXTERNAL') or (not args.load_balancing_scheme))): # This is NetLB using a backend service. Scheme is either explicitly # EXTERNAL or not supplied (EXTERNAL is the default scheme). # API fields allPorts, ports, and portRange are mutually exclusive. # All three API fields are valid for this case. # Use of L3_DEFAULT implies all ports even if allPorts is unset. if ports_all_specified: forwarding_rule.allPorts = True elif range_list: if len(range_list) > 1: # More than one port, potentially discontiguous, from --ports= flag. forwarding_rule.ports = [ six.text_type(p) for p in _GetPortList(range_list) ] else: # Exactly one value from --ports= flag. Might be a single port (80); # might be a range (80-90). Since it might be a range, the portRange # API attribute is more appropriate. forwarding_rule.portRange = six.text_type(range_list[0]) elif args.port_range: forwarding_rule.portRange = _MakeSingleUnifiedPortRange( args.port_range, range_list) elif ((target_ref.Collection() == 'compute.targetPool' or target_ref.Collection() == 'compute.targetInstances') and ((args.load_balancing_scheme == 'EXTERNAL') or (not args.load_balancing_scheme))): # This is NetLB using a target pool or external protocol forwarding. # Scheme is either explicitly EXTERNAL or not supplied (EXTERNAL is the # default scheme). # API fields allPorts, ports, and portRange are mutually exclusive. # API field ports is not valid for this case. # Use of L3_DEFAULT implies all ports by definition. if ports_all_specified: forwarding_rule.allPorts = True else: forwarding_rule.portRange = _MakeSingleUnifiedPortRange( args.port_range, range_list) else: # All other regional forwarding rules with load balancing scheme EXTERNAL. forwarding_rule.portRange = _MakeSingleUnifiedPortRange( args.port_range, range_list) if hasattr(args, 'service_label'): forwarding_rule.serviceLabel = args.service_label if self._support_global_access and args.IsSpecified('allow_global_access'): forwarding_rule.allowGlobalAccess = args.allow_global_access if self._support_psc_global_access and args.IsSpecified( 'allow_psc_global_access'): forwarding_rule.allowPscGlobalAccess = args.allow_psc_global_access if self._support_disable_automate_dns_zone and args.IsSpecified( 'disable_automate_dns_zone'): forwarding_rule.noAutomateDnsZone = args.disable_automate_dns_zone if hasattr(args, 'is_mirroring_collector'): forwarding_rule.isMirroringCollector = args.is_mirroring_collector if hasattr(args, 'service_directory_registration' ) and args.service_directory_registration: if is_psc_ilb: # Parse projects/../locations/../namespaces/.. match = re.match( r'^projects/([^/]+)/locations/([^/]+)/namespaces/([^/]+)$', args.service_directory_registration) if not match: raise exceptions.InvalidArgumentException( '--service-directory-registration', 'If set, must be of the form projects/PROJECT/locations/REGION/namespaces/NAMESPACE' ) project = match.group(1) region = match.group(2) if project != forwarding_rule_ref.project or region != forwarding_rule_ref.region: raise exceptions.InvalidArgumentException( '--service-directory-registration', 'Service Directory registration must be in the same project and region as the forwarding rule.' ) sd_registration = client.messages.ForwardingRuleServiceDirectoryRegistration( namespace=match.group(3)) forwarding_rule.serviceDirectoryRegistrations.append(sd_registration) else: if not self._support_sd_registration_for_regional: raise exceptions.InvalidArgumentException( '--service-directory-registration', """flag is available in one or more alternate release tracks. Try: gcloud alpha compute forwarding-rules create --service-directory-registration gcloud beta compute forwarding-rules create --service-directory-registration""" ) # Parse projects/../locations/../namespaces/../services/.. match = re.match( r'^projects/([^/]+)/locations/([^/]+)/namespaces/([^/]+)/services/([^/]+)$', args.service_directory_registration) if not match: raise exceptions.InvalidArgumentException( '--service-directory-registration', 'Must be of the form projects/PROJECT/locations/REGION/namespaces/NAMESPACE/services/SERVICE' ) project = match.group(1) region = match.group(2) if project != forwarding_rule_ref.project or region != forwarding_rule_ref.region: raise exceptions.InvalidArgumentException( '--service-directory-registration', 'Service Directory registration must be in the same project and region as the forwarding rule.' ) sd_registration = client.messages.ForwardingRuleServiceDirectoryRegistration( namespace=match.group(3), service=match.group(4)) forwarding_rule.serviceDirectoryRegistrations.append(sd_registration) request = client.messages.ComputeForwardingRulesInsertRequest( forwardingRule=forwarding_rule, project=forwarding_rule_ref.project, region=forwarding_rule_ref.region) return [(client.apitools_client.forwardingRules, 'Insert', request)]