| 1 |
|
| 2 |
|
| 3 |
|
| 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 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
const _ = connect.IsAtLeastVersion1_13_0 |
| 22 |
|
| 23 |
const ( |
| 24 |
|
| 25 |
UserServiceName = "svc.user.v1.UserService" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
const ( |
| 36 |
|
| 37 |
UserServiceWhoamiProcedure = "/svc.user.v1.UserService/Whoami" |
| 38 |
|
| 39 |
|
| 40 |
UserServiceGetLogoutURLProcedure = "/svc.user.v1.UserService/GetLogoutURL" |
| 41 |
|
| 42 |
|
| 43 |
UserServiceRefreshUserTokenProcedure = "/svc.user.v1.UserService/RefreshUserToken" |
| 44 |
|
| 45 |
UserServiceUpdateUserProcedure = "/svc.user.v1.UserService/UpdateUser" |
| 46 |
|
| 47 |
|
| 48 |
UserServiceCreateOrganizationProcedure = "/svc.user.v1.UserService/CreateOrganization" |
| 49 |
|
| 50 |
|
| 51 |
UserServiceListOrganizationProcedure = "/svc.user.v1.UserService/ListOrganization" |
| 52 |
) |
| 53 |
|
| 54 |
|
| 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 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 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 |
|
| 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 |
} |