コード例 #1
0
    def delete(self):
        stub = vpn_tunnel_pb2_grpc.ComputeVpnTunnelServiceStub(
            channel.Channel())
        request = vpn_tunnel_pb2.DeleteComputeVpnTunnelRequest()
        request.service_account_file = self.service_account_file
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

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

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

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

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

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

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

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

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

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

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

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

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

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

        response = stub.DeleteComputeVpnTunnel(request)
コード例 #2
0
    def list(self, project, region, service_account_file=""):
        stub = vpn_tunnel_pb2_grpc.ComputeVpnTunnelServiceStub(
            channel.Channel())
        request = vpn_tunnel_pb2.ListComputeVpnTunnelRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Region = region

        return stub.ListComputeVpnTunnel(request).items
コード例 #3
0
    def delete(self, project, region, name, service_account_file=""):
        stub = vpn_tunnel_pb2_grpc.ComputeVpnTunnelServiceStub(
            channel.Channel())
        request = vpn_tunnel_pb2.DeleteComputeVpnTunnelRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Region = region

        request.Name = name

        response = stub.DeleteComputeVpnTunnel(request)
コード例 #4
0
    def apply(self):
        stub = vpn_tunnel_pb2_grpc.ComputeVpnTunnelServiceStub(
            channel.Channel())
        request = vpn_tunnel_pb2.ApplyComputeVpnTunnelRequest()
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

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

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

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

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

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

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

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

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

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

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

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

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

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

        request.service_account_file = self.service_account_file

        response = stub.ApplyComputeVpnTunnel(request)
        self.id = Primitive.from_proto(response.id)
        self.name = Primitive.from_proto(response.name)
        self.description = Primitive.from_proto(response.description)
        self.region = Primitive.from_proto(response.region)
        self.target_vpn_gateway = Primitive.from_proto(
            response.target_vpn_gateway)
        self.vpn_gateway = Primitive.from_proto(response.vpn_gateway)
        self.vpn_gateway_interface = Primitive.from_proto(
            response.vpn_gateway_interface)
        self.peer_external_gateway = Primitive.from_proto(
            response.peer_external_gateway)
        self.peer_external_gateway_interface = Primitive.from_proto(
            response.peer_external_gateway_interface)
        self.peer_gcp_gateway = Primitive.from_proto(response.peer_gcp_gateway)
        self.router = Primitive.from_proto(response.router)
        self.peer_ip = Primitive.from_proto(response.peer_ip)
        self.shared_secret = Primitive.from_proto(response.shared_secret)
        self.shared_secret_hash = Primitive.from_proto(
            response.shared_secret_hash)
        self.status = VpnTunnelStatusEnum.from_proto(response.status)
        self.self_link = Primitive.from_proto(response.self_link)
        self.ike_version = Primitive.from_proto(response.ike_version)
        self.detailed_status = Primitive.from_proto(response.detailed_status)
        self.local_traffic_selector = Primitive.from_proto(
            response.local_traffic_selector)
        self.remote_traffic_selector = Primitive.from_proto(
            response.remote_traffic_selector)
        self.project = Primitive.from_proto(response.project)