Пример #1
0
    def list(self, project, location, service_account_file=""):
        stub = forwarding_rule_pb2_grpc.ComputeBetaForwardingRuleServiceStub(
            channel.Channel())
        request = forwarding_rule_pb2.ListComputeBetaForwardingRuleRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        return stub.ListComputeBetaForwardingRule(request).items
Пример #2
0
    def delete(self, project, location, name, service_account_file=""):
        stub = forwarding_rule_pb2_grpc.ComputeBetaForwardingRuleServiceStub(
            channel.Channel())
        request = forwarding_rule_pb2.DeleteComputeBetaForwardingRuleRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        request.Name = name

        response = stub.DeleteComputeBetaForwardingRule(request)
    def apply(self):
        stub = forwarding_rule_pb2_grpc.ComputeBetaForwardingRuleServiceStub(
            channel.Channel()
        )
        request = forwarding_rule_pb2.ApplyComputeBetaForwardingRuleRequest()
        if Primitive.to_proto(self.all_ports):
            request.resource.all_ports = Primitive.to_proto(self.all_ports)

        if Primitive.to_proto(self.allow_global_access):
            request.resource.allow_global_access = Primitive.to_proto(
                self.allow_global_access
            )

        if Primitive.to_proto(self.backend_service):
            request.resource.backend_service = Primitive.to_proto(self.backend_service)

        if Primitive.to_proto(self.creation_timestamp):
            request.resource.creation_timestamp = Primitive.to_proto(
                self.creation_timestamp
            )

        if Primitive.to_proto(self.description):
            request.resource.description = Primitive.to_proto(self.description)

        if Primitive.to_proto(self.ip_address):
            request.resource.ip_address = Primitive.to_proto(self.ip_address)

        if ForwardingRuleIPProtocolEnum.to_proto(self.ip_protocol):
            request.resource.ip_protocol = ForwardingRuleIPProtocolEnum.to_proto(
                self.ip_protocol
            )

        if ForwardingRuleIPVersionEnum.to_proto(self.ip_version):
            request.resource.ip_version = ForwardingRuleIPVersionEnum.to_proto(
                self.ip_version
            )

        if Primitive.to_proto(self.is_mirroring_collector):
            request.resource.is_mirroring_collector = Primitive.to_proto(
                self.is_mirroring_collector
            )

        if ForwardingRuleLoadBalancingSchemeEnum.to_proto(self.load_balancing_scheme):
            request.resource.load_balancing_scheme = ForwardingRuleLoadBalancingSchemeEnum.to_proto(
                self.load_balancing_scheme
            )

        if ForwardingRuleMetadataFilterArray.to_proto(self.metadata_filter):
            request.resource.metadata_filter.extend(
                ForwardingRuleMetadataFilterArray.to_proto(self.metadata_filter)
            )
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if Primitive.to_proto(self.network):
            request.resource.network = Primitive.to_proto(self.network)

        if ForwardingRuleNetworkTierEnum.to_proto(self.network_tier):
            request.resource.network_tier = ForwardingRuleNetworkTierEnum.to_proto(
                self.network_tier
            )

        if Primitive.to_proto(self.port_range):
            request.resource.port_range = Primitive.to_proto(self.port_range)

        if Primitive.to_proto(self.ports):
            request.resource.ports.extend(Primitive.to_proto(self.ports))
        if Primitive.to_proto(self.region):
            request.resource.region = Primitive.to_proto(self.region)

        if Primitive.to_proto(self.self_link):
            request.resource.self_link = Primitive.to_proto(self.self_link)

        if Primitive.to_proto(self.service_label):
            request.resource.service_label = Primitive.to_proto(self.service_label)

        if Primitive.to_proto(self.service_name):
            request.resource.service_name = Primitive.to_proto(self.service_name)

        if Primitive.to_proto(self.subnetwork):
            request.resource.subnetwork = Primitive.to_proto(self.subnetwork)

        if Primitive.to_proto(self.target):
            request.resource.target = Primitive.to_proto(self.target)

        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if Primitive.to_proto(self.location):
            request.resource.location = Primitive.to_proto(self.location)

        request.service_account_file = self.service_account_file

        response = stub.ApplyComputeBetaForwardingRule(request)
        self.all_ports = Primitive.from_proto(response.all_ports)
        self.allow_global_access = Primitive.from_proto(response.allow_global_access)
        self.backend_service = Primitive.from_proto(response.backend_service)
        self.creation_timestamp = Primitive.from_proto(response.creation_timestamp)
        self.description = Primitive.from_proto(response.description)
        self.ip_address = Primitive.from_proto(response.ip_address)
        self.ip_protocol = ForwardingRuleIPProtocolEnum.from_proto(response.ip_protocol)
        self.ip_version = ForwardingRuleIPVersionEnum.from_proto(response.ip_version)
        self.is_mirroring_collector = Primitive.from_proto(
            response.is_mirroring_collector
        )
        self.load_balancing_scheme = ForwardingRuleLoadBalancingSchemeEnum.from_proto(
            response.load_balancing_scheme
        )
        self.metadata_filter = ForwardingRuleMetadataFilterArray.from_proto(
            response.metadata_filter
        )
        self.name = Primitive.from_proto(response.name)
        self.network = Primitive.from_proto(response.network)
        self.network_tier = ForwardingRuleNetworkTierEnum.from_proto(
            response.network_tier
        )
        self.port_range = Primitive.from_proto(response.port_range)
        self.ports = Primitive.from_proto(response.ports)
        self.region = Primitive.from_proto(response.region)
        self.self_link = Primitive.from_proto(response.self_link)
        self.service_label = Primitive.from_proto(response.service_label)
        self.service_name = Primitive.from_proto(response.service_name)
        self.subnetwork = Primitive.from_proto(response.subnetwork)
        self.target = Primitive.from_proto(response.target)
        self.project = Primitive.from_proto(response.project)
        self.location = Primitive.from_proto(response.location)