Debian Codegraph @

go/svc/token/v1/tokenv1connect/service.connect.go

raw symbols SCIP
1 // Code generated by protoc-gen-connect-go. DO NOT EDIT.
2 //
3 // Source: svc/token/v1/service.proto
4
5 package tokenv1connect
6
7 import (
8 connect "connectrpc.com/connect"
9 context "context"
10 errors "errors"
11 v1 "github.com/humanlogio/api/go/svc/token/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 // TokenServiceName is the fully-qualified name of the TokenService service.
25 TokenServiceName = "svc.token.v1.TokenService"
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 // TokenServiceGenerateEnvironmentTokenProcedure is the fully-qualified name of the TokenService's
37 // GenerateEnvironmentToken RPC.
38 TokenServiceGenerateEnvironmentTokenProcedure = "/svc.token.v1.TokenService/GenerateEnvironmentToken"
39 // TokenServiceRevokeEnvironmentTokenProcedure is the fully-qualified name of the TokenService's
40 // RevokeEnvironmentToken RPC.
41 TokenServiceRevokeEnvironmentTokenProcedure = "/svc.token.v1.TokenService/RevokeEnvironmentToken"
42 // TokenServiceGetEnvironmentTokenProcedure is the fully-qualified name of the TokenService's
43 // GetEnvironmentToken RPC.
44 TokenServiceGetEnvironmentTokenProcedure = "/svc.token.v1.TokenService/GetEnvironmentToken"
45 // TokenServiceListEnvironmentTokenProcedure is the fully-qualified name of the TokenService's
46 // ListEnvironmentToken RPC.
47 TokenServiceListEnvironmentTokenProcedure = "/svc.token.v1.TokenService/ListEnvironmentToken"
48 )
49
50 // TokenServiceClient is a client for the svc.token.v1.TokenService service.
51 type TokenServiceClient interface {
52 GenerateEnvironmentToken(context.Context, *connect.Request[v1.GenerateEnvironmentTokenRequest]) (*connect.Response[v1.GenerateEnvironmentTokenResponse], error)
53 RevokeEnvironmentToken(context.Context, *connect.Request[v1.RevokeEnvironmentTokenRequest]) (*connect.Response[v1.RevokeEnvironmentTokenResponse], error)
54 GetEnvironmentToken(context.Context, *connect.Request[v1.GetEnvironmentTokenRequest]) (*connect.Response[v1.GetEnvironmentTokenResponse], error)
55 ListEnvironmentToken(context.Context, *connect.Request[v1.ListEnvironmentTokenRequest]) (*connect.Response[v1.ListEnvironmentTokenResponse], error)
56 }
57
58 // NewTokenServiceClient constructs a client for the svc.token.v1.TokenService service. By default,
59 // it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and
60 // sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC()
61 // or connect.WithGRPCWeb() options.
62 //
63 // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
64 // http://api.acme.com or https://acme.com/grpc).
65 func NewTokenServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) TokenServiceClient {
66 baseURL = strings.TrimRight(baseURL, "/")
67 tokenServiceMethods := v1.File_svc_token_v1_service_proto.Services().ByName("TokenService").Methods()
68 return &tokenServiceClient{
69 generateEnvironmentToken: connect.NewClient[v1.GenerateEnvironmentTokenRequest, v1.GenerateEnvironmentTokenResponse](
70 httpClient,
71 baseURL+TokenServiceGenerateEnvironmentTokenProcedure,
72 connect.WithSchema(tokenServiceMethods.ByName("GenerateEnvironmentToken")),
73 connect.WithClientOptions(opts...),
74 ),
75 revokeEnvironmentToken: connect.NewClient[v1.RevokeEnvironmentTokenRequest, v1.RevokeEnvironmentTokenResponse](
76 httpClient,
77 baseURL+TokenServiceRevokeEnvironmentTokenProcedure,
78 connect.WithSchema(tokenServiceMethods.ByName("RevokeEnvironmentToken")),
79 connect.WithClientOptions(opts...),
80 ),
81 getEnvironmentToken: connect.NewClient[v1.GetEnvironmentTokenRequest, v1.GetEnvironmentTokenResponse](
82 httpClient,
83 baseURL+TokenServiceGetEnvironmentTokenProcedure,
84 connect.WithSchema(tokenServiceMethods.ByName("GetEnvironmentToken")),
85 connect.WithClientOptions(opts...),
86 ),
87 listEnvironmentToken: connect.NewClient[v1.ListEnvironmentTokenRequest, v1.ListEnvironmentTokenResponse](
88 httpClient,
89 baseURL+TokenServiceListEnvironmentTokenProcedure,
90 connect.WithSchema(tokenServiceMethods.ByName("ListEnvironmentToken")),
91 connect.WithClientOptions(opts...),
92 ),
93 }
94 }
95
96 // tokenServiceClient implements TokenServiceClient.
97 type tokenServiceClient struct {
98 generateEnvironmentToken *connect.Client[v1.GenerateEnvironmentTokenRequest, v1.GenerateEnvironmentTokenResponse]
99 revokeEnvironmentToken *connect.Client[v1.RevokeEnvironmentTokenRequest, v1.RevokeEnvironmentTokenResponse]
100 getEnvironmentToken *connect.Client[v1.GetEnvironmentTokenRequest, v1.GetEnvironmentTokenResponse]
101 listEnvironmentToken *connect.Client[v1.ListEnvironmentTokenRequest, v1.ListEnvironmentTokenResponse]
102 }
103
104 // GenerateEnvironmentToken calls svc.token.v1.TokenService.GenerateEnvironmentToken.
105 func (c *tokenServiceClient) GenerateEnvironmentToken(ctx context.Context, req *connect.Request[v1.GenerateEnvironmentTokenRequest]) (*connect.Response[v1.GenerateEnvironmentTokenResponse], error) {
106 return c.generateEnvironmentToken.CallUnary(ctx, req)
107 }
108
109 // RevokeEnvironmentToken calls svc.token.v1.TokenService.RevokeEnvironmentToken.
110 func (c *tokenServiceClient) RevokeEnvironmentToken(ctx context.Context, req *connect.Request[v1.RevokeEnvironmentTokenRequest]) (*connect.Response[v1.RevokeEnvironmentTokenResponse], error) {
111 return c.revokeEnvironmentToken.CallUnary(ctx, req)
112 }
113
114 // GetEnvironmentToken calls svc.token.v1.TokenService.GetEnvironmentToken.
115 func (c *tokenServiceClient) GetEnvironmentToken(ctx context.Context, req *connect.Request[v1.GetEnvironmentTokenRequest]) (*connect.Response[v1.GetEnvironmentTokenResponse], error) {
116 return c.getEnvironmentToken.CallUnary(ctx, req)
117 }
118
119 // ListEnvironmentToken calls svc.token.v1.TokenService.ListEnvironmentToken.
120 func (c *tokenServiceClient) ListEnvironmentToken(ctx context.Context, req *connect.Request[v1.ListEnvironmentTokenRequest]) (*connect.Response[v1.ListEnvironmentTokenResponse], error) {
121 return c.listEnvironmentToken.CallUnary(ctx, req)
122 }
123
124 // TokenServiceHandler is an implementation of the svc.token.v1.TokenService service.
125 type TokenServiceHandler interface {
126 GenerateEnvironmentToken(context.Context, *connect.Request[v1.GenerateEnvironmentTokenRequest]) (*connect.Response[v1.GenerateEnvironmentTokenResponse], error)
127 RevokeEnvironmentToken(context.Context, *connect.Request[v1.RevokeEnvironmentTokenRequest]) (*connect.Response[v1.RevokeEnvironmentTokenResponse], error)
128 GetEnvironmentToken(context.Context, *connect.Request[v1.GetEnvironmentTokenRequest]) (*connect.Response[v1.GetEnvironmentTokenResponse], error)
129 ListEnvironmentToken(context.Context, *connect.Request[v1.ListEnvironmentTokenRequest]) (*connect.Response[v1.ListEnvironmentTokenResponse], error)
130 }
131
132 // NewTokenServiceHandler builds an HTTP handler from the service implementation. It returns the
133 // path on which to mount the handler and the handler itself.
134 //
135 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
136 // and JSON codecs. They also support gzip compression.
137 func NewTokenServiceHandler(svc TokenServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
138 tokenServiceMethods := v1.File_svc_token_v1_service_proto.Services().ByName("TokenService").Methods()
139 tokenServiceGenerateEnvironmentTokenHandler := connect.NewUnaryHandler(
140 TokenServiceGenerateEnvironmentTokenProcedure,
141 svc.GenerateEnvironmentToken,
142 connect.WithSchema(tokenServiceMethods.ByName("GenerateEnvironmentToken")),
143 connect.WithHandlerOptions(opts...),
144 )
145 tokenServiceRevokeEnvironmentTokenHandler := connect.NewUnaryHandler(
146 TokenServiceRevokeEnvironmentTokenProcedure,
147 svc.RevokeEnvironmentToken,
148 connect.WithSchema(tokenServiceMethods.ByName("RevokeEnvironmentToken")),
149 connect.WithHandlerOptions(opts...),
150 )
151 tokenServiceGetEnvironmentTokenHandler := connect.NewUnaryHandler(
152 TokenServiceGetEnvironmentTokenProcedure,
153 svc.GetEnvironmentToken,
154 connect.WithSchema(tokenServiceMethods.ByName("GetEnvironmentToken")),
155 connect.WithHandlerOptions(opts...),
156 )
157 tokenServiceListEnvironmentTokenHandler := connect.NewUnaryHandler(
158 TokenServiceListEnvironmentTokenProcedure,
159 svc.ListEnvironmentToken,
160 connect.WithSchema(tokenServiceMethods.ByName("ListEnvironmentToken")),
161 connect.WithHandlerOptions(opts...),
162 )
163 return "/svc.token.v1.TokenService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
164 switch r.URL.Path {
165 case TokenServiceGenerateEnvironmentTokenProcedure:
166 tokenServiceGenerateEnvironmentTokenHandler.ServeHTTP(w, r)
167 case TokenServiceRevokeEnvironmentTokenProcedure:
168 tokenServiceRevokeEnvironmentTokenHandler.ServeHTTP(w, r)
169 case TokenServiceGetEnvironmentTokenProcedure:
170 tokenServiceGetEnvironmentTokenHandler.ServeHTTP(w, r)
171 case TokenServiceListEnvironmentTokenProcedure:
172 tokenServiceListEnvironmentTokenHandler.ServeHTTP(w, r)
173 default:
174 http.NotFound(w, r)
175 }
176 })
177 }
178
179 // UnimplementedTokenServiceHandler returns CodeUnimplemented from all methods.
180 type UnimplementedTokenServiceHandler struct{}
181
182 func (UnimplementedTokenServiceHandler) GenerateEnvironmentToken(context.Context, *connect.Request[v1.GenerateEnvironmentTokenRequest]) (*connect.Response[v1.GenerateEnvironmentTokenResponse], error) {
183 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.token.v1.TokenService.GenerateEnvironmentToken is not implemented"))
184 }
185
186 func (UnimplementedTokenServiceHandler) RevokeEnvironmentToken(context.Context, *connect.Request[v1.RevokeEnvironmentTokenRequest]) (*connect.Response[v1.RevokeEnvironmentTokenResponse], error) {
187 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.token.v1.TokenService.RevokeEnvironmentToken is not implemented"))
188 }
189
190 func (UnimplementedTokenServiceHandler) GetEnvironmentToken(context.Context, *connect.Request[v1.GetEnvironmentTokenRequest]) (*connect.Response[v1.GetEnvironmentTokenResponse], error) {
191 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.token.v1.TokenService.GetEnvironmentToken is not implemented"))
192 }
193
194 func (UnimplementedTokenServiceHandler) ListEnvironmentToken(context.Context, *connect.Request[v1.ListEnvironmentTokenRequest]) (*connect.Response[v1.ListEnvironmentTokenResponse], error) {
195 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.token.v1.TokenService.ListEnvironmentToken is not implemented"))
196 }