v0.4.0 72f8f2e

token.connect.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3// Code generated by protoc-gen-connect-go. DO NOT EDIT.
4//
5// Source: ermite/token.proto
6
7package ermiteconnect
8
9import (
10	ermite "bnema.dev/ermite-api/gen/ermite"
11	connect "connectrpc.com/connect"
12	context "context"
13	errors "errors"
14	http "net/http"
15	strings "strings"
16)
17
18// This is a compile-time assertion to ensure that this generated file and the connect package are
19// compatible. If you get a compiler error that this constant is not defined, this code was
20// generated with a version of connect newer than the one compiled into your binary. You can fix the
21// problem by either regenerating this code with an older version of connect or updating the connect
22// version compiled into your binary.
23const _ = connect.IsAtLeastVersion1_13_0
24
25const (
26	// TokenServiceName is the fully-qualified name of the TokenService service.
27	TokenServiceName = "ermite.TokenService"
28)
29
30// These constants are the fully-qualified names of the RPCs defined in this package. They're
31// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
32//
33// Note that these are different from the fully-qualified method names used by
34// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
35// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
36// period.
37const (
38	// TokenServiceCreateTokenProcedure is the fully-qualified name of the TokenService's CreateToken
39	// RPC.
40	TokenServiceCreateTokenProcedure = "/ermite.TokenService/CreateToken"
41	// TokenServiceListTokensProcedure is the fully-qualified name of the TokenService's ListTokens RPC.
42	TokenServiceListTokensProcedure = "/ermite.TokenService/ListTokens"
43	// TokenServiceRevokeTokenProcedure is the fully-qualified name of the TokenService's RevokeToken
44	// RPC.
45	TokenServiceRevokeTokenProcedure = "/ermite.TokenService/RevokeToken"
46)
47
48// TokenServiceClient is a client for the ermite.TokenService service.
49type TokenServiceClient interface {
50	// CreateToken creates a token and returns its secret. The secret is shown
51	// only in this response and cannot be retrieved later. Fails with
52	// permission_denied when the new token would exceed the caller's limits and
53	// with invalid_argument when scopes is empty or contains SCOPE_UNSPECIFIED.
54	CreateToken(context.Context, *connect.Request[ermite.CreateTokenRequest]) (*connect.Response[ermite.CreateTokenResponse], error)
55	// ListTokens lists stored tokens, newest first.
56	ListTokens(context.Context, *connect.Request[ermite.ListTokensRequest]) (*connect.Response[ermite.ListTokensResponse], error)
57	// RevokeToken deletes a token; it stops working immediately. Fails with
58	// not_found if the id is unknown.
59	RevokeToken(context.Context, *connect.Request[ermite.RevokeTokenRequest]) (*connect.Response[ermite.RevokeTokenResponse], error)
60}
61
62// NewTokenServiceClient constructs a client for the ermite.TokenService service. By default, it
63// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
64// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
65// connect.WithGRPCWeb() options.
66//
67// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
68// http://api.acme.com or https://acme.com/grpc).
69func NewTokenServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) TokenServiceClient {
70	baseURL = strings.TrimRight(baseURL, "/")
71	tokenServiceMethods := ermite.File_ermite_token_proto.Services().ByName("TokenService").Methods()
72	return &tokenServiceClient{
73		createToken: connect.NewClient[ermite.CreateTokenRequest, ermite.CreateTokenResponse](
74			httpClient,
75			baseURL+TokenServiceCreateTokenProcedure,
76			connect.WithSchema(tokenServiceMethods.ByName("CreateToken")),
77			connect.WithClientOptions(opts...),
78		),
79		listTokens: connect.NewClient[ermite.ListTokensRequest, ermite.ListTokensResponse](
80			httpClient,
81			baseURL+TokenServiceListTokensProcedure,
82			connect.WithSchema(tokenServiceMethods.ByName("ListTokens")),
83			connect.WithClientOptions(opts...),
84		),
85		revokeToken: connect.NewClient[ermite.RevokeTokenRequest, ermite.RevokeTokenResponse](
86			httpClient,
87			baseURL+TokenServiceRevokeTokenProcedure,
88			connect.WithSchema(tokenServiceMethods.ByName("RevokeToken")),
89			connect.WithClientOptions(opts...),
90		),
91	}
92}
93
94// tokenServiceClient implements TokenServiceClient.
95type tokenServiceClient struct {
96	createToken *connect.Client[ermite.CreateTokenRequest, ermite.CreateTokenResponse]
97	listTokens  *connect.Client[ermite.ListTokensRequest, ermite.ListTokensResponse]
98	revokeToken *connect.Client[ermite.RevokeTokenRequest, ermite.RevokeTokenResponse]
99}
100
101// CreateToken calls ermite.TokenService.CreateToken.
102func (c *tokenServiceClient) CreateToken(ctx context.Context, req *connect.Request[ermite.CreateTokenRequest]) (*connect.Response[ermite.CreateTokenResponse], error) {
103	return c.createToken.CallUnary(ctx, req)
104}
105
106// ListTokens calls ermite.TokenService.ListTokens.
107func (c *tokenServiceClient) ListTokens(ctx context.Context, req *connect.Request[ermite.ListTokensRequest]) (*connect.Response[ermite.ListTokensResponse], error) {
108	return c.listTokens.CallUnary(ctx, req)
109}
110
111// RevokeToken calls ermite.TokenService.RevokeToken.
112func (c *tokenServiceClient) RevokeToken(ctx context.Context, req *connect.Request[ermite.RevokeTokenRequest]) (*connect.Response[ermite.RevokeTokenResponse], error) {
113	return c.revokeToken.CallUnary(ctx, req)
114}
115
116// TokenServiceHandler is an implementation of the ermite.TokenService service.
117type TokenServiceHandler interface {
118	// CreateToken creates a token and returns its secret. The secret is shown
119	// only in this response and cannot be retrieved later. Fails with
120	// permission_denied when the new token would exceed the caller's limits and
121	// with invalid_argument when scopes is empty or contains SCOPE_UNSPECIFIED.
122	CreateToken(context.Context, *connect.Request[ermite.CreateTokenRequest]) (*connect.Response[ermite.CreateTokenResponse], error)
123	// ListTokens lists stored tokens, newest first.
124	ListTokens(context.Context, *connect.Request[ermite.ListTokensRequest]) (*connect.Response[ermite.ListTokensResponse], error)
125	// RevokeToken deletes a token; it stops working immediately. Fails with
126	// not_found if the id is unknown.
127	RevokeToken(context.Context, *connect.Request[ermite.RevokeTokenRequest]) (*connect.Response[ermite.RevokeTokenResponse], error)
128}
129
130// NewTokenServiceHandler builds an HTTP handler from the service implementation. It returns the
131// path on which to mount the handler and the handler itself.
132//
133// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
134// and JSON codecs. They also support gzip compression.
135func NewTokenServiceHandler(svc TokenServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
136	tokenServiceMethods := ermite.File_ermite_token_proto.Services().ByName("TokenService").Methods()
137	tokenServiceCreateTokenHandler := connect.NewUnaryHandler(
138		TokenServiceCreateTokenProcedure,
139		svc.CreateToken,
140		connect.WithSchema(tokenServiceMethods.ByName("CreateToken")),
141		connect.WithHandlerOptions(opts...),
142	)
143	tokenServiceListTokensHandler := connect.NewUnaryHandler(
144		TokenServiceListTokensProcedure,
145		svc.ListTokens,
146		connect.WithSchema(tokenServiceMethods.ByName("ListTokens")),
147		connect.WithHandlerOptions(opts...),
148	)
149	tokenServiceRevokeTokenHandler := connect.NewUnaryHandler(
150		TokenServiceRevokeTokenProcedure,
151		svc.RevokeToken,
152		connect.WithSchema(tokenServiceMethods.ByName("RevokeToken")),
153		connect.WithHandlerOptions(opts...),
154	)
155	return "/ermite.TokenService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
156		switch r.URL.Path {
157		case TokenServiceCreateTokenProcedure:
158			tokenServiceCreateTokenHandler.ServeHTTP(w, r)
159		case TokenServiceListTokensProcedure:
160			tokenServiceListTokensHandler.ServeHTTP(w, r)
161		case TokenServiceRevokeTokenProcedure:
162			tokenServiceRevokeTokenHandler.ServeHTTP(w, r)
163		default:
164			http.NotFound(w, r)
165		}
166	})
167}
168
169// UnimplementedTokenServiceHandler returns CodeUnimplemented from all methods.
170type UnimplementedTokenServiceHandler struct{}
171
172func (UnimplementedTokenServiceHandler) CreateToken(context.Context, *connect.Request[ermite.CreateTokenRequest]) (*connect.Response[ermite.CreateTokenResponse], error) {
173	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.TokenService.CreateToken is not implemented"))
174}
175
176func (UnimplementedTokenServiceHandler) ListTokens(context.Context, *connect.Request[ermite.ListTokensRequest]) (*connect.Response[ermite.ListTokensResponse], error) {
177	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.TokenService.ListTokens is not implemented"))
178}
179
180func (UnimplementedTokenServiceHandler) RevokeToken(context.Context, *connect.Request[ermite.RevokeTokenRequest]) (*connect.Response[ermite.RevokeTokenResponse], error) {
181	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.TokenService.RevokeToken is not implemented"))
182}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 18

↑↓ moveenter openesc close