Debian Codegraph @

go/svc/user/v1/userv1connect/service.connect.go

raw symbols SCIP
1 // Code generated by protoc-gen-connect-go. DO NOT EDIT.
2 //
3 // Source: svc/user/v1/service.proto
4
5 package userv1connect
6
7 import (
8 connect "connectrpc.com/connect"
9 context "context"
10 errors "errors"
11 v1 "github.com/humanlogio/api/go/svc/user/v1"
12 http "net/http"
13 strings "strings"
14 )
15
16 // This is a compile-time assertion to ensure that this generated file and the connect package are
17 // compatible. If you get a compiler error that this constant is not defined, this code was
18 // generated with a version of connect newer than the one compiled into your binary. You can fix the
19 // problem by either regenerating this code with an older version of connect or updating the connect
20 // version compiled into your binary.
21 const _ = connect.IsAtLeastVersion1_13_0
22
23 const (
24 // UserServiceName is the fully-qualified name of the UserService service.
25 UserServiceName = "svc.user.v1.UserService"
26 )
27
28 // These constants are the fully-qualified names of the RPCs defined in this package. They're
29 // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
30 //
31 // Note that these are different from the fully-qualified method names used by
32 // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
33 // reflection-formatted method names, remove the leading slash and convert the remaining slash to a
34 // period.
35 const (
36 // UserServiceWhoamiProcedure is the fully-qualified name of the UserService's Whoami RPC.
37 UserServiceWhoamiProcedure = "/svc.user.v1.UserService/Whoami"
38 // UserServiceGetLogoutURLProcedure is the fully-qualified name of the UserService's GetLogoutURL
39 // RPC.
40 UserServiceGetLogoutURLProcedure = "/svc.user.v1.UserService/GetLogoutURL"
41 // UserServiceRefreshUserTokenProcedure is the fully-qualified name of the UserService's
42 // RefreshUserToken RPC.
43 UserServiceRefreshUserTokenProcedure = "/svc.user.v1.UserService/RefreshUserToken"
44 // UserServiceUpdateUserProcedure is the fully-qualified name of the UserService's UpdateUser RPC.
45 UserServiceUpdateUserProcedure = "/svc.user.v1.UserService/UpdateUser"
46 // UserServiceCreateOrganizationProcedure is the fully-qualified name of the UserService's
47 // CreateOrganization RPC.
48 UserServiceCreateOrganizationProcedure = "/svc.user.v1.UserService/CreateOrganization"
49 // UserServiceListOrganizationProcedure is the fully-qualified name of the UserService's
50 // ListOrganization RPC.
51 UserServiceListOrganizationProcedure = "/svc.user.v1.UserService/ListOrganization"
52 )
53
54 // UserServiceClient is a client for the svc.user.v1.UserService service.
55 type UserServiceClient interface {
56 Whoami(context.Context, *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error)
57 GetLogoutURL(context.Context, *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error)
58 RefreshUserToken(context.Context, *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error)
59 UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error)
60 CreateOrganization(context.Context, *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error)
61 ListOrganization(context.Context, *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error)
62 }
63
64 // NewUserServiceClient constructs a client for the svc.user.v1.UserService service. By default, it
65 // uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
66 // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
67 // connect.WithGRPCWeb() options.
68 //
69 // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
70 // http://api.acme.com or https://acme.com/grpc).
71 func NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) UserServiceClient {
72 baseURL = strings.TrimRight(baseURL, "/")
73 userServiceMethods := v1.File_svc_user_v1_service_proto.Services().ByName("UserService").Methods()
74 return &userServiceClient{
75 whoami: connect.NewClient[v1.WhoamiRequest, v1.WhoamiResponse](
76 httpClient,
77 baseURL+UserServiceWhoamiProcedure,
78 connect.WithSchema(userServiceMethods.ByName("Whoami")),
79 connect.WithClientOptions(opts...),
80 ),
81 getLogoutURL: connect.NewClient[v1.GetLogoutURLRequest, v1.GetLogoutURLResponse](
82 httpClient,
83 baseURL+UserServiceGetLogoutURLProcedure,
84 connect.WithSchema(userServiceMethods.ByName("GetLogoutURL")),
85 connect.WithClientOptions(opts...),
86 ),
87 refreshUserToken: connect.NewClient[v1.RefreshUserTokenRequest, v1.RefreshUserTokenResponse](
88 httpClient,
89 baseURL+UserServiceRefreshUserTokenProcedure,
90 connect.WithSchema(userServiceMethods.ByName("RefreshUserToken")),
91 connect.WithClientOptions(opts...),
92 ),
93 updateUser: connect.NewClient[v1.UpdateUserRequest, v1.UpdateUserResponse](
94 httpClient,
95 baseURL+UserServiceUpdateUserProcedure,
96 connect.WithSchema(userServiceMethods.ByName("UpdateUser")),
97 connect.WithClientOptions(opts...),
98 ),
99 createOrganization: connect.NewClient[v1.CreateOrganizationRequest, v1.CreateOrganizationResponse](
100 httpClient,
101 baseURL+UserServiceCreateOrganizationProcedure,
102 connect.WithSchema(userServiceMethods.ByName("CreateOrganization")),
103 connect.WithClientOptions(opts...),
104 ),
105 listOrganization: connect.NewClient[v1.ListOrganizationRequest, v1.ListOrganizationResponse](
106 httpClient,
107 baseURL+UserServiceListOrganizationProcedure,
108 connect.WithSchema(userServiceMethods.ByName("ListOrganization")),
109 connect.WithClientOptions(opts...),
110 ),
111 }
112 }
113
114 // userServiceClient implements UserServiceClient.
115 type userServiceClient struct {
116 whoami *connect.Client[v1.WhoamiRequest, v1.WhoamiResponse]
117 getLogoutURL *connect.Client[v1.GetLogoutURLRequest, v1.GetLogoutURLResponse]
118 refreshUserToken *connect.Client[v1.RefreshUserTokenRequest, v1.RefreshUserTokenResponse]
119 updateUser *connect.Client[v1.UpdateUserRequest, v1.UpdateUserResponse]
120 createOrganization *connect.Client[v1.CreateOrganizationRequest, v1.CreateOrganizationResponse]
121 listOrganization *connect.Client[v1.ListOrganizationRequest, v1.ListOrganizationResponse]
122 }
123
124 // Whoami calls svc.user.v1.UserService.Whoami.
125 func (c *userServiceClient) Whoami(ctx context.Context, req *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error) {
126 return c.whoami.CallUnary(ctx, req)
127 }
128
129 // GetLogoutURL calls svc.user.v1.UserService.GetLogoutURL.
130 func (c *userServiceClient) GetLogoutURL(ctx context.Context, req *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error) {
131 return c.getLogoutURL.CallUnary(ctx, req)
132 }
133
134 // RefreshUserToken calls svc.user.v1.UserService.RefreshUserToken.
135 func (c *userServiceClient) RefreshUserToken(ctx context.Context, req *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error) {
136 return c.refreshUserToken.CallUnary(ctx, req)
137 }
138
139 // UpdateUser calls svc.user.v1.UserService.UpdateUser.
140 func (c *userServiceClient) UpdateUser(ctx context.Context, req *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error) {
141 return c.updateUser.CallUnary(ctx, req)
142 }
143
144 // CreateOrganization calls svc.user.v1.UserService.CreateOrganization.
145 func (c *userServiceClient) CreateOrganization(ctx context.Context, req *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error) {
146 return c.createOrganization.CallUnary(ctx, req)
147 }
148
149 // ListOrganization calls svc.user.v1.UserService.ListOrganization.
150 func (c *userServiceClient) ListOrganization(ctx context.Context, req *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error) {
151 return c.listOrganization.CallUnary(ctx, req)
152 }
153
154 // UserServiceHandler is an implementation of the svc.user.v1.UserService service.
155 type UserServiceHandler interface {
156 Whoami(context.Context, *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error)
157 GetLogoutURL(context.Context, *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error)
158 RefreshUserToken(context.Context, *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error)
159 UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error)
160 CreateOrganization(context.Context, *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error)
161 ListOrganization(context.Context, *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error)
162 }
163
164 // NewUserServiceHandler builds an HTTP handler from the service implementation. It returns the path
165 // on which to mount the handler and the handler itself.
166 //
167 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
168 // and JSON codecs. They also support gzip compression.
169 func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
170 userServiceMethods := v1.File_svc_user_v1_service_proto.Services().ByName("UserService").Methods()
171 userServiceWhoamiHandler := connect.NewUnaryHandler(
172 UserServiceWhoamiProcedure,
173 svc.Whoami,
174 connect.WithSchema(userServiceMethods.ByName("Whoami")),
175 connect.WithHandlerOptions(opts...),
176 )
177 userServiceGetLogoutURLHandler := connect.NewUnaryHandler(
178 UserServiceGetLogoutURLProcedure,
179 svc.GetLogoutURL,
180 connect.WithSchema(userServiceMethods.ByName("GetLogoutURL")),
181 connect.WithHandlerOptions(opts...),
182 )
183 userServiceRefreshUserTokenHandler := connect.NewUnaryHandler(
184 UserServiceRefreshUserTokenProcedure,
185 svc.RefreshUserToken,
186 connect.WithSchema(userServiceMethods.ByName("RefreshUserToken")),
187 connect.WithHandlerOptions(opts...),
188 )
189 userServiceUpdateUserHandler := connect.NewUnaryHandler(
190 UserServiceUpdateUserProcedure,
191 svc.UpdateUser,
192 connect.WithSchema(userServiceMethods.ByName("UpdateUser")),
193 connect.WithHandlerOptions(opts...),
194 )
195 userServiceCreateOrganizationHandler := connect.NewUnaryHandler(
196 UserServiceCreateOrganizationProcedure,
197 svc.CreateOrganization,
198 connect.WithSchema(userServiceMethods.ByName("CreateOrganization")),
199 connect.WithHandlerOptions(opts...),
200 )
201 userServiceListOrganizationHandler := connect.NewUnaryHandler(
202 UserServiceListOrganizationProcedure,
203 svc.ListOrganization,
204 connect.WithSchema(userServiceMethods.ByName("ListOrganization")),
205 connect.WithHandlerOptions(opts...),
206 )
207 return "/svc.user.v1.UserService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
208 switch r.URL.Path {
209 case UserServiceWhoamiProcedure:
210 userServiceWhoamiHandler.ServeHTTP(w, r)
211 case UserServiceGetLogoutURLProcedure:
212 userServiceGetLogoutURLHandler.ServeHTTP(w, r)
213 case UserServiceRefreshUserTokenProcedure:
214 userServiceRefreshUserTokenHandler.ServeHTTP(w, r)
215 case UserServiceUpdateUserProcedure:
216 userServiceUpdateUserHandler.ServeHTTP(w, r)
217 case UserServiceCreateOrganizationProcedure:
218 userServiceCreateOrganizationHandler.ServeHTTP(w, r)
219 case UserServiceListOrganizationProcedure:
220 userServiceListOrganizationHandler.ServeHTTP(w, r)
221 default:
222 http.NotFound(w, r)
223 }
224 })
225 }
226
227 // UnimplementedUserServiceHandler returns CodeUnimplemented from all methods.
228 type UnimplementedUserServiceHandler struct{}
229
230 func (UnimplementedUserServiceHandler) Whoami(context.Context, *connect.Request[v1.WhoamiRequest]) (*connect.Response[v1.WhoamiResponse], error) {
231 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.Whoami is not implemented"))
232 }
233
234 func (UnimplementedUserServiceHandler) GetLogoutURL(context.Context, *connect.Request[v1.GetLogoutURLRequest]) (*connect.Response[v1.GetLogoutURLResponse], error) {
235 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.GetLogoutURL is not implemented"))
236 }
237
238 func (UnimplementedUserServiceHandler) RefreshUserToken(context.Context, *connect.Request[v1.RefreshUserTokenRequest]) (*connect.Response[v1.RefreshUserTokenResponse], error) {
239 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.RefreshUserToken is not implemented"))
240 }
241
242 func (UnimplementedUserServiceHandler) UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.UpdateUserResponse], error) {
243 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.UpdateUser is not implemented"))
244 }
245
246 func (UnimplementedUserServiceHandler) CreateOrganization(context.Context, *connect.Request[v1.CreateOrganizationRequest]) (*connect.Response[v1.CreateOrganizationResponse], error) {
247 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.CreateOrganization is not implemented"))
248 }
249
250 func (UnimplementedUserServiceHandler) ListOrganization(context.Context, *connect.Request[v1.ListOrganizationRequest]) (*connect.Response[v1.ListOrganizationResponse], error) {
251 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.user.v1.UserService.ListOrganization is not implemented"))
252 }