File: service.connect.go

package info (click to toggle)
golang-github-humanlogio-api 0.0~git20250305.fa41d14-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,352 kB
  • sloc: sh: 45; makefile: 8
file content (252 lines) | stat: -rw-r--r-- 13,374 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: svc/user/v1/service.proto

package userv1connect

import (
	connect "connectrpc.com/connect"
	context "context"
	errors "errors"
	v1 "github.com/humanlogio/api/go/svc/user/v1"
	http "net/http"
	strings "strings"
)

// 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 (
	// UserServiceName is the fully-qualified name of the UserService service.
	UserServiceName = "svc.user.v1.UserService"
)

// 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 (
	// UserServiceWhoamiProcedure is the fully-qualified name of the UserService's Whoami RPC.
	UserServiceWhoamiProcedure = "/svc.user.v1.UserService/Whoami"
	// UserServiceGetLogoutURLProcedure is the fully-qualified name of the UserService's GetLogoutURL
	// RPC.
	UserServiceGetLogoutURLProcedure = "/svc.user.v1.UserService/GetLogoutURL"
	// UserServiceRefreshUserTokenProcedure is the fully-qualified name of the UserService's
	// RefreshUserToken RPC.
	UserServiceRefreshUserTokenProcedure = "/svc.user.v1.UserService/RefreshUserToken"
	// UserServiceUpdateUserProcedure is the fully-qualified name of the UserService's UpdateUser RPC.
	UserServiceUpdateUserProcedure = "/svc.user.v1.UserService/UpdateUser"
	// UserServiceCreateOrganizationProcedure is the fully-qualified name of the UserService's
	// CreateOrganization RPC.
	UserServiceCreateOrganizationProcedure = "/svc.user.v1.UserService/CreateOrganization"
	// UserServiceListOrganizationProcedure is the fully-qualified name of the UserService's
	// ListOrganization RPC.
	UserServiceListOrganizationProcedure = "/svc.user.v1.UserService/ListOrganization"
)

// UserServiceClient is a client for the svc.user.v1.UserService service.
type UserServiceClient interface {
	Whoami(context.Context, *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error)
	GetLogoutURL(context.Context, *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error)
	RefreshUserToken(context.Context, *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error)
	UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error)
	CreateOrganization(context.Context, *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error)
	ListOrganization(context.Context, *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error)
}

// NewUserServiceClient constructs a client for the svc.user.v1.UserService 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 NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) UserServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	userServiceMethods := v1.File_svc_user_v1_service_proto.Services().ByName("UserService").Methods()
	return &userServiceClient{
		whoami: connect.NewClient[v1.WhoamiRequest, v1.WhoamiResponse](
			httpClient,
			baseURL+UserServiceWhoamiProcedure,
			connect.WithSchema(userServiceMethods.ByName("Whoami")),
			connect.WithClientOptions(opts...),
		),
		getLogoutURL: connect.NewClient[v1.GetLogoutURLRequest, v1.GetLogoutURLResponse](
			httpClient,
			baseURL+UserServiceGetLogoutURLProcedure,
			connect.WithSchema(userServiceMethods.ByName("GetLogoutURL")),
			connect.WithClientOptions(opts...),
		),
		refreshUserToken: connect.NewClient[v1.RefreshUserTokenRequest, v1.RefreshUserTokenResponse](
			httpClient,
			baseURL+UserServiceRefreshUserTokenProcedure,
			connect.WithSchema(userServiceMethods.ByName("RefreshUserToken")),
			connect.WithClientOptions(opts...),
		),
		updateUser: connect.NewClient[v1.UpdateUserRequest, v1.UpdateUserResponse](
			httpClient,
			baseURL+UserServiceUpdateUserProcedure,
			connect.WithSchema(userServiceMethods.ByName("UpdateUser")),
			connect.WithClientOptions(opts...),
		),
		createOrganization: connect.NewClient[v1.CreateOrganizationRequest, v1.CreateOrganizationResponse](
			httpClient,
			baseURL+UserServiceCreateOrganizationProcedure,
			connect.WithSchema(userServiceMethods.ByName("CreateOrganization")),
			connect.WithClientOptions(opts...),
		),
		listOrganization: connect.NewClient[v1.ListOrganizationRequest, v1.ListOrganizationResponse](
			httpClient,
			baseURL+UserServiceListOrganizationProcedure,
			connect.WithSchema(userServiceMethods.ByName("ListOrganization")),
			connect.WithClientOptions(opts...),
		),
	}
}

// userServiceClient implements UserServiceClient.
type userServiceClient struct {
	whoami             *connect.Client[v1.WhoamiRequest, v1.WhoamiResponse]
	getLogoutURL       *connect.Client[v1.GetLogoutURLRequest, v1.GetLogoutURLResponse]
	refreshUserToken   *connect.Client[v1.RefreshUserTokenRequest, v1.RefreshUserTokenResponse]
	updateUser         *connect.Client[v1.UpdateUserRequest, v1.UpdateUserResponse]
	createOrganization *connect.Client[v1.CreateOrganizationRequest, v1.CreateOrganizationResponse]
	listOrganization   *connect.Client[v1.ListOrganizationRequest, v1.ListOrganizationResponse]
}

// Whoami calls svc.user.v1.UserService.Whoami.
func (c *userServiceClient) Whoami(ctx context.Context, req *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error) {
	return c.whoami.CallUnary(ctx, req)
}

// GetLogoutURL calls svc.user.v1.UserService.GetLogoutURL.
func (c *userServiceClient) GetLogoutURL(ctx context.Context, req *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error) {
	return c.getLogoutURL.CallUnary(ctx, req)
}

// RefreshUserToken calls svc.user.v1.UserService.RefreshUserToken.
func (c *userServiceClient) RefreshUserToken(ctx context.Context, req *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error) {
	return c.refreshUserToken.CallUnary(ctx, req)
}

// UpdateUser calls svc.user.v1.UserService.UpdateUser.
func (c *userServiceClient) UpdateUser(ctx context.Context, req *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error) {
	return c.updateUser.CallUnary(ctx, req)
}

// CreateOrganization calls svc.user.v1.UserService.CreateOrganization.
func (c *userServiceClient) CreateOrganization(ctx context.Context, req *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error) {
	return c.createOrganization.CallUnary(ctx, req)
}

// ListOrganization calls svc.user.v1.UserService.ListOrganization.
func (c *userServiceClient) ListOrganization(ctx context.Context, req *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error) {
	return c.listOrganization.CallUnary(ctx, req)
}

// UserServiceHandler is an implementation of the svc.user.v1.UserService service.
type UserServiceHandler interface {
	Whoami(context.Context, *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error)
	GetLogoutURL(context.Context, *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error)
	RefreshUserToken(context.Context, *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error)
	UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error)
	CreateOrganization(context.Context, *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error)
	ListOrganization(context.Context, *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error)
}

// NewUserServiceHandler 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 NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	userServiceMethods := v1.File_svc_user_v1_service_proto.Services().ByName("UserService").Methods()
	userServiceWhoamiHandler := connect.NewUnaryHandler(
		UserServiceWhoamiProcedure,
		svc.Whoami,
		connect.WithSchema(userServiceMethods.ByName("Whoami")),
		connect.WithHandlerOptions(opts...),
	)
	userServiceGetLogoutURLHandler := connect.NewUnaryHandler(
		UserServiceGetLogoutURLProcedure,
		svc.GetLogoutURL,
		connect.WithSchema(userServiceMethods.ByName("GetLogoutURL")),
		connect.WithHandlerOptions(opts...),
	)
	userServiceRefreshUserTokenHandler := connect.NewUnaryHandler(
		UserServiceRefreshUserTokenProcedure,
		svc.RefreshUserToken,
		connect.WithSchema(userServiceMethods.ByName("RefreshUserToken")),
		connect.WithHandlerOptions(opts...),
	)
	userServiceUpdateUserHandler := connect.NewUnaryHandler(
		UserServiceUpdateUserProcedure,
		svc.UpdateUser,
		connect.WithSchema(userServiceMethods.ByName("UpdateUser")),
		connect.WithHandlerOptions(opts...),
	)
	userServiceCreateOrganizationHandler := connect.NewUnaryHandler(
		UserServiceCreateOrganizationProcedure,
		svc.CreateOrganization,
		connect.WithSchema(userServiceMethods.ByName("CreateOrganization")),
		connect.WithHandlerOptions(opts...),
	)
	userServiceListOrganizationHandler := connect.NewUnaryHandler(
		UserServiceListOrganizationProcedure,
		svc.ListOrganization,
		connect.WithSchema(userServiceMethods.ByName("ListOrganization")),
		connect.WithHandlerOptions(opts...),
	)
	return "/svc.user.v1.UserService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case UserServiceWhoamiProcedure:
			userServiceWhoamiHandler.ServeHTTP(w, r)
		case UserServiceGetLogoutURLProcedure:
			userServiceGetLogoutURLHandler.ServeHTTP(w, r)
		case UserServiceRefreshUserTokenProcedure:
			userServiceRefreshUserTokenHandler.ServeHTTP(w, r)
		case UserServiceUpdateUserProcedure:
			userServiceUpdateUserHandler.ServeHTTP(w, r)
		case UserServiceCreateOrganizationProcedure:
			userServiceCreateOrganizationHandler.ServeHTTP(w, r)
		case UserServiceListOrganizationProcedure:
			userServiceListOrganizationHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

// UnimplementedUserServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedUserServiceHandler struct{}

func (UnimplementedUserServiceHandler) Whoami(context.Context, *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.Whoami is not implemented"))
}

func (UnimplementedUserServiceHandler) GetLogoutURL(context.Context, *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.GetLogoutURL is not implemented"))
}

func (UnimplementedUserServiceHandler) RefreshUserToken(context.Context, *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.RefreshUserToken is not implemented"))
}

func (UnimplementedUserServiceHandler) UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.UpdateUser is not implemented"))
}

func (UnimplementedUserServiceHandler) CreateOrganization(context.Context, *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.CreateOrganization is not implemented"))
}

func (UnimplementedUserServiceHandler) ListOrganization(context.Context, *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.ListOrganization is not implemented"))
}