grpc setup

This commit is contained in:
royalcat 2024-10-10 16:47:32 +03:00
parent b6f84af6bd
commit 12e3e605af
10 changed files with 1148 additions and 5 deletions
src/delivery/grpcserver/gen/vpn/v1

View file

@ -0,0 +1,379 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.35.1
// protoc (unknown)
// source: vpn/v1/vpn.proto
package vpnv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type CreateProfileRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FlavorId string `protobuf:"bytes,1,opt,name=flavor_id,json=flavorId,proto3" json:"flavor_id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *CreateProfileRequest) Reset() {
*x = CreateProfileRequest{}
mi := &file_vpn_v1_vpn_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateProfileRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateProfileRequest) ProtoMessage() {}
func (x *CreateProfileRequest) ProtoReflect() protoreflect.Message {
mi := &file_vpn_v1_vpn_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateProfileRequest.ProtoReflect.Descriptor instead.
func (*CreateProfileRequest) Descriptor() ([]byte, []int) {
return file_vpn_v1_vpn_proto_rawDescGZIP(), []int{0}
}
func (x *CreateProfileRequest) GetFlavorId() string {
if x != nil {
return x.FlavorId
}
return ""
}
func (x *CreateProfileRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type CreateProfileResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
ConnectionString *string `protobuf:"bytes,2,opt,name=connection_string,json=connectionString,proto3,oneof" json:"connection_string,omitempty"`
}
func (x *CreateProfileResponse) Reset() {
*x = CreateProfileResponse{}
mi := &file_vpn_v1_vpn_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateProfileResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateProfileResponse) ProtoMessage() {}
func (x *CreateProfileResponse) ProtoReflect() protoreflect.Message {
mi := &file_vpn_v1_vpn_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateProfileResponse.ProtoReflect.Descriptor instead.
func (*CreateProfileResponse) Descriptor() ([]byte, []int) {
return file_vpn_v1_vpn_proto_rawDescGZIP(), []int{1}
}
func (x *CreateProfileResponse) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *CreateProfileResponse) GetConnectionString() string {
if x != nil && x.ConnectionString != nil {
return *x.ConnectionString
}
return ""
}
type AvaliableFlavorsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *AvaliableFlavorsRequest) Reset() {
*x = AvaliableFlavorsRequest{}
mi := &file_vpn_v1_vpn_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AvaliableFlavorsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AvaliableFlavorsRequest) ProtoMessage() {}
func (x *AvaliableFlavorsRequest) ProtoReflect() protoreflect.Message {
mi := &file_vpn_v1_vpn_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AvaliableFlavorsRequest.ProtoReflect.Descriptor instead.
func (*AvaliableFlavorsRequest) Descriptor() ([]byte, []int) {
return file_vpn_v1_vpn_proto_rawDescGZIP(), []int{2}
}
type AvaliableFlavorsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Flavors []*Flavor `protobuf:"bytes,1,rep,name=flavors,proto3" json:"flavors,omitempty"`
}
func (x *AvaliableFlavorsResponse) Reset() {
*x = AvaliableFlavorsResponse{}
mi := &file_vpn_v1_vpn_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AvaliableFlavorsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AvaliableFlavorsResponse) ProtoMessage() {}
func (x *AvaliableFlavorsResponse) ProtoReflect() protoreflect.Message {
mi := &file_vpn_v1_vpn_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AvaliableFlavorsResponse.ProtoReflect.Descriptor instead.
func (*AvaliableFlavorsResponse) Descriptor() ([]byte, []int) {
return file_vpn_v1_vpn_proto_rawDescGZIP(), []int{3}
}
func (x *AvaliableFlavorsResponse) GetFlavors() []*Flavor {
if x != nil {
return x.Flavors
}
return nil
}
type Flavor struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
}
func (x *Flavor) Reset() {
*x = Flavor{}
mi := &file_vpn_v1_vpn_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Flavor) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Flavor) ProtoMessage() {}
func (x *Flavor) ProtoReflect() protoreflect.Message {
mi := &file_vpn_v1_vpn_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Flavor.ProtoReflect.Descriptor instead.
func (*Flavor) Descriptor() ([]byte, []int) {
return file_vpn_v1_vpn_proto_rawDescGZIP(), []int{4}
}
func (x *Flavor) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Flavor) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Flavor) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
var File_vpn_v1_vpn_proto protoreflect.FileDescriptor
var file_vpn_v1_vpn_proto_rawDesc = []byte{
0x0a, 0x10, 0x76, 0x70, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x70, 0x6e, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x06, 0x76, 0x70, 0x6e, 0x2e, 0x76, 0x31, 0x22, 0x47, 0x0a, 0x14, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x49, 0x64, 0x12,
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x22, 0x6f, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f,
0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x11,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e,
0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x88, 0x01, 0x01, 0x42, 0x14,
0x0a, 0x12, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x22, 0x19, 0x0a, 0x17, 0x41, 0x76, 0x61, 0x6c, 0x69, 0x61, 0x62, 0x6c,
0x65, 0x46, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22,
0x44, 0x0a, 0x18, 0x41, 0x76, 0x61, 0x6c, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6c, 0x61, 0x76,
0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x66,
0x6c, 0x61, 0x76, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76,
0x70, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x52, 0x07, 0x66, 0x6c,
0x61, 0x76, 0x6f, 0x72, 0x73, 0x22, 0x4e, 0x0a, 0x06, 0x46, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x12,
0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12,
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xba, 0x01, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c,
0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x10, 0x41, 0x76, 0x61,
0x6c, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x73, 0x12, 0x1f, 0x2e,
0x76, 0x70, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x76, 0x61, 0x6c, 0x69, 0x61, 0x62, 0x6c, 0x65,
0x46, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20,
0x2e, 0x76, 0x70, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x76, 0x61, 0x6c, 0x69, 0x61, 0x62, 0x6c,
0x65, 0x46, 0x6c, 0x61, 0x76, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x4e, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66,
0x69, 0x6c, 0x65, 0x12, 0x1c, 0x2e, 0x76, 0x70, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65,
0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1d, 0x2e, 0x76, 0x70, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74,
0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x42, 0x91, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x70, 0x6e, 0x2e, 0x76,
0x31, 0x42, 0x08, 0x56, 0x70, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x76,
0x70, 0x6e, 0x2e, 0x6b, 0x6f, 0x6e, 0x66, 0x61, 0x2e, 0x63, 0x68, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x72, 0x63, 0x2f, 0x64, 0x65, 0x6c, 0x69, 0x76,
0x65, 0x72, 0x79, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x67,
0x65, 0x6e, 0x2f, 0x76, 0x70, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x70, 0x6e, 0x76, 0x31, 0xa2,
0x02, 0x03, 0x56, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x56, 0x70, 0x6e, 0x2e, 0x56, 0x31, 0xca, 0x02,
0x06, 0x56, 0x70, 0x6e, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x56, 0x70, 0x6e, 0x5c, 0x56, 0x31,
0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x56,
0x70, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_vpn_v1_vpn_proto_rawDescOnce sync.Once
file_vpn_v1_vpn_proto_rawDescData = file_vpn_v1_vpn_proto_rawDesc
)
func file_vpn_v1_vpn_proto_rawDescGZIP() []byte {
file_vpn_v1_vpn_proto_rawDescOnce.Do(func() {
file_vpn_v1_vpn_proto_rawDescData = protoimpl.X.CompressGZIP(file_vpn_v1_vpn_proto_rawDescData)
})
return file_vpn_v1_vpn_proto_rawDescData
}
var file_vpn_v1_vpn_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_vpn_v1_vpn_proto_goTypes = []any{
(*CreateProfileRequest)(nil), // 0: vpn.v1.CreateProfileRequest
(*CreateProfileResponse)(nil), // 1: vpn.v1.CreateProfileResponse
(*AvaliableFlavorsRequest)(nil), // 2: vpn.v1.AvaliableFlavorsRequest
(*AvaliableFlavorsResponse)(nil), // 3: vpn.v1.AvaliableFlavorsResponse
(*Flavor)(nil), // 4: vpn.v1.Flavor
}
var file_vpn_v1_vpn_proto_depIdxs = []int32{
4, // 0: vpn.v1.AvaliableFlavorsResponse.flavors:type_name -> vpn.v1.Flavor
2, // 1: vpn.v1.ProfilesService.AvaliableFlavors:input_type -> vpn.v1.AvaliableFlavorsRequest
0, // 2: vpn.v1.ProfilesService.CreateProfile:input_type -> vpn.v1.CreateProfileRequest
3, // 3: vpn.v1.ProfilesService.AvaliableFlavors:output_type -> vpn.v1.AvaliableFlavorsResponse
1, // 4: vpn.v1.ProfilesService.CreateProfile:output_type -> vpn.v1.CreateProfileResponse
3, // [3:5] is the sub-list for method output_type
1, // [1:3] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_vpn_v1_vpn_proto_init() }
func file_vpn_v1_vpn_proto_init() {
if File_vpn_v1_vpn_proto != nil {
return
}
file_vpn_v1_vpn_proto_msgTypes[1].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_vpn_v1_vpn_proto_rawDesc,
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_vpn_v1_vpn_proto_goTypes,
DependencyIndexes: file_vpn_v1_vpn_proto_depIdxs,
MessageInfos: file_vpn_v1_vpn_proto_msgTypes,
}.Build()
File_vpn_v1_vpn_proto = out.File
file_vpn_v1_vpn_proto_rawDesc = nil
file_vpn_v1_vpn_proto_goTypes = nil
file_vpn_v1_vpn_proto_depIdxs = nil
}

View file

@ -0,0 +1,143 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: vpn/v1/vpn.proto
package vpnv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
http "net/http"
strings "strings"
v1 "vpn.konfa.ch/controller/src/delivery/grpcserver/gen/vpn/v1"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// ProfilesServiceName is the fully-qualified name of the ProfilesService service.
ProfilesServiceName = "vpn.v1.ProfilesService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// ProfilesServiceAvaliableFlavorsProcedure is the fully-qualified name of the ProfilesService's
// AvaliableFlavors RPC.
ProfilesServiceAvaliableFlavorsProcedure = "/vpn.v1.ProfilesService/AvaliableFlavors"
// ProfilesServiceCreateProfileProcedure is the fully-qualified name of the ProfilesService's
// CreateProfile RPC.
ProfilesServiceCreateProfileProcedure = "/vpn.v1.ProfilesService/CreateProfile"
)
// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package.
var (
profilesServiceServiceDescriptor = v1.File_vpn_v1_vpn_proto.Services().ByName("ProfilesService")
profilesServiceAvaliableFlavorsMethodDescriptor = profilesServiceServiceDescriptor.Methods().ByName("AvaliableFlavors")
profilesServiceCreateProfileMethodDescriptor = profilesServiceServiceDescriptor.Methods().ByName("CreateProfile")
)
// ProfilesServiceClient is a client for the vpn.v1.ProfilesService service.
type ProfilesServiceClient interface {
AvaliableFlavors(context.Context, *connect.Request[v1.AvaliableFlavorsRequest]) (*connect.Response[v1.AvaliableFlavorsResponse], error)
CreateProfile(context.Context, *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error)
}
// NewProfilesServiceClient constructs a client for the vpn.v1.ProfilesService service. By default,
// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and
// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC()
// or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewProfilesServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ProfilesServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
return &profilesServiceClient{
avaliableFlavors: connect.NewClient[v1.AvaliableFlavorsRequest, v1.AvaliableFlavorsResponse](
httpClient,
baseURL+ProfilesServiceAvaliableFlavorsProcedure,
connect.WithSchema(profilesServiceAvaliableFlavorsMethodDescriptor),
connect.WithClientOptions(opts...),
),
createProfile: connect.NewClient[v1.CreateProfileRequest, v1.CreateProfileResponse](
httpClient,
baseURL+ProfilesServiceCreateProfileProcedure,
connect.WithSchema(profilesServiceCreateProfileMethodDescriptor),
connect.WithClientOptions(opts...),
),
}
}
// profilesServiceClient implements ProfilesServiceClient.
type profilesServiceClient struct {
avaliableFlavors *connect.Client[v1.AvaliableFlavorsRequest, v1.AvaliableFlavorsResponse]
createProfile *connect.Client[v1.CreateProfileRequest, v1.CreateProfileResponse]
}
// AvaliableFlavors calls vpn.v1.ProfilesService.AvaliableFlavors.
func (c *profilesServiceClient) AvaliableFlavors(ctx context.Context, req *connect.Request[v1.AvaliableFlavorsRequest]) (*connect.Response[v1.AvaliableFlavorsResponse], error) {
return c.avaliableFlavors.CallUnary(ctx, req)
}
// CreateProfile calls vpn.v1.ProfilesService.CreateProfile.
func (c *profilesServiceClient) CreateProfile(ctx context.Context, req *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error) {
return c.createProfile.CallUnary(ctx, req)
}
// ProfilesServiceHandler is an implementation of the vpn.v1.ProfilesService service.
type ProfilesServiceHandler interface {
AvaliableFlavors(context.Context, *connect.Request[v1.AvaliableFlavorsRequest]) (*connect.Response[v1.AvaliableFlavorsResponse], error)
CreateProfile(context.Context, *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error)
}
// NewProfilesServiceHandler builds an HTTP handler from the service implementation. It returns the
// path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewProfilesServiceHandler(svc ProfilesServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
profilesServiceAvaliableFlavorsHandler := connect.NewUnaryHandler(
ProfilesServiceAvaliableFlavorsProcedure,
svc.AvaliableFlavors,
connect.WithSchema(profilesServiceAvaliableFlavorsMethodDescriptor),
connect.WithHandlerOptions(opts...),
)
profilesServiceCreateProfileHandler := connect.NewUnaryHandler(
ProfilesServiceCreateProfileProcedure,
svc.CreateProfile,
connect.WithSchema(profilesServiceCreateProfileMethodDescriptor),
connect.WithHandlerOptions(opts...),
)
return "/vpn.v1.ProfilesService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case ProfilesServiceAvaliableFlavorsProcedure:
profilesServiceAvaliableFlavorsHandler.ServeHTTP(w, r)
case ProfilesServiceCreateProfileProcedure:
profilesServiceCreateProfileHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedProfilesServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedProfilesServiceHandler struct{}
func (UnimplementedProfilesServiceHandler) AvaliableFlavors(context.Context, *connect.Request[v1.AvaliableFlavorsRequest]) (*connect.Response[v1.AvaliableFlavorsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("vpn.v1.ProfilesService.AvaliableFlavors is not implemented"))
}
func (UnimplementedProfilesServiceHandler) CreateProfile(context.Context, *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("vpn.v1.ProfilesService.CreateProfile is not implemented"))
}