-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathapi.connect.go
331 lines (295 loc) · 16.5 KB
/
api.connect.go
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/api.proto
package apiconnect
import (
context "context"
errors "errors"
connect_go "github.com/bufbuild/connect-go"
api "github.com/nix-community/trustix/packages/trustix-proto/api"
schema "github.com/nix-community/trustix/packages/trustix-proto/schema"
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_go.IsAtLeastVersion0_1_0
const (
// NodeAPIName is the fully-qualified name of the NodeAPI service.
NodeAPIName = "trustix_api.v1.NodeAPI"
// LogAPIName is the fully-qualified name of the LogAPI service.
LogAPIName = "trustix_api.v1.LogAPI"
)
// NodeAPIClient is a client for the trustix_api.v1.NodeAPI service.
type NodeAPIClient interface {
// Get a list of all logs published by this node
Logs(context.Context, *connect_go.Request[api.LogsRequest]) (*connect_go.Response[api.LogsResponse], error)
// Get values by their content-address
GetValue(context.Context, *connect_go.Request[api.ValueRequest]) (*connect_go.Response[api.ValueResponse], error)
}
// NewNodeAPIClient constructs a client for the trustix_api.v1.NodeAPI 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 NewNodeAPIClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) NodeAPIClient {
baseURL = strings.TrimRight(baseURL, "/")
return &nodeAPIClient{
logs: connect_go.NewClient[api.LogsRequest, api.LogsResponse](
httpClient,
baseURL+"/trustix_api.v1.NodeAPI/Logs",
opts...,
),
getValue: connect_go.NewClient[api.ValueRequest, api.ValueResponse](
httpClient,
baseURL+"/trustix_api.v1.NodeAPI/GetValue",
opts...,
),
}
}
// nodeAPIClient implements NodeAPIClient.
type nodeAPIClient struct {
logs *connect_go.Client[api.LogsRequest, api.LogsResponse]
getValue *connect_go.Client[api.ValueRequest, api.ValueResponse]
}
// Logs calls trustix_api.v1.NodeAPI.Logs.
func (c *nodeAPIClient) Logs(ctx context.Context, req *connect_go.Request[api.LogsRequest]) (*connect_go.Response[api.LogsResponse], error) {
return c.logs.CallUnary(ctx, req)
}
// GetValue calls trustix_api.v1.NodeAPI.GetValue.
func (c *nodeAPIClient) GetValue(ctx context.Context, req *connect_go.Request[api.ValueRequest]) (*connect_go.Response[api.ValueResponse], error) {
return c.getValue.CallUnary(ctx, req)
}
// NodeAPIHandler is an implementation of the trustix_api.v1.NodeAPI service.
type NodeAPIHandler interface {
// Get a list of all logs published by this node
Logs(context.Context, *connect_go.Request[api.LogsRequest]) (*connect_go.Response[api.LogsResponse], error)
// Get values by their content-address
GetValue(context.Context, *connect_go.Request[api.ValueRequest]) (*connect_go.Response[api.ValueResponse], error)
}
// NewNodeAPIHandler 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 NewNodeAPIHandler(svc NodeAPIHandler, opts ...connect_go.HandlerOption) (string, http.Handler) {
mux := http.NewServeMux()
mux.Handle("/trustix_api.v1.NodeAPI/Logs", connect_go.NewUnaryHandler(
"/trustix_api.v1.NodeAPI/Logs",
svc.Logs,
opts...,
))
mux.Handle("/trustix_api.v1.NodeAPI/GetValue", connect_go.NewUnaryHandler(
"/trustix_api.v1.NodeAPI/GetValue",
svc.GetValue,
opts...,
))
return "/trustix_api.v1.NodeAPI/", mux
}
// UnimplementedNodeAPIHandler returns CodeUnimplemented from all methods.
type UnimplementedNodeAPIHandler struct{}
func (UnimplementedNodeAPIHandler) Logs(context.Context, *connect_go.Request[api.LogsRequest]) (*connect_go.Response[api.LogsResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.NodeAPI.Logs is not implemented"))
}
func (UnimplementedNodeAPIHandler) GetValue(context.Context, *connect_go.Request[api.ValueRequest]) (*connect_go.Response[api.ValueResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.NodeAPI.GetValue is not implemented"))
}
// LogAPIClient is a client for the trustix_api.v1.LogAPI service.
type LogAPIClient interface {
// Get signed head
GetHead(context.Context, *connect_go.Request[api.LogHeadRequest]) (*connect_go.Response[schema.LogHead], error)
GetLogConsistencyProof(context.Context, *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetLogAuditProof(context.Context, *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetLogEntries(context.Context, *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error)
GetMapValue(context.Context, *connect_go.Request[api.GetMapValueRequest]) (*connect_go.Response[api.MapValueResponse], error)
GetMHLogConsistencyProof(context.Context, *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetMHLogAuditProof(context.Context, *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetMHLogEntries(context.Context, *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error)
}
// NewLogAPIClient constructs a client for the trustix_api.v1.LogAPI 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 NewLogAPIClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) LogAPIClient {
baseURL = strings.TrimRight(baseURL, "/")
return &logAPIClient{
getHead: connect_go.NewClient[api.LogHeadRequest, schema.LogHead](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetHead",
opts...,
),
getLogConsistencyProof: connect_go.NewClient[api.GetLogConsistencyProofRequest, api.ProofResponse](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetLogConsistencyProof",
opts...,
),
getLogAuditProof: connect_go.NewClient[api.GetLogAuditProofRequest, api.ProofResponse](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetLogAuditProof",
opts...,
),
getLogEntries: connect_go.NewClient[api.GetLogEntriesRequest, api.LogEntriesResponse](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetLogEntries",
opts...,
),
getMapValue: connect_go.NewClient[api.GetMapValueRequest, api.MapValueResponse](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetMapValue",
opts...,
),
getMHLogConsistencyProof: connect_go.NewClient[api.GetLogConsistencyProofRequest, api.ProofResponse](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetMHLogConsistencyProof",
opts...,
),
getMHLogAuditProof: connect_go.NewClient[api.GetLogAuditProofRequest, api.ProofResponse](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetMHLogAuditProof",
opts...,
),
getMHLogEntries: connect_go.NewClient[api.GetLogEntriesRequest, api.LogEntriesResponse](
httpClient,
baseURL+"/trustix_api.v1.LogAPI/GetMHLogEntries",
opts...,
),
}
}
// logAPIClient implements LogAPIClient.
type logAPIClient struct {
getHead *connect_go.Client[api.LogHeadRequest, schema.LogHead]
getLogConsistencyProof *connect_go.Client[api.GetLogConsistencyProofRequest, api.ProofResponse]
getLogAuditProof *connect_go.Client[api.GetLogAuditProofRequest, api.ProofResponse]
getLogEntries *connect_go.Client[api.GetLogEntriesRequest, api.LogEntriesResponse]
getMapValue *connect_go.Client[api.GetMapValueRequest, api.MapValueResponse]
getMHLogConsistencyProof *connect_go.Client[api.GetLogConsistencyProofRequest, api.ProofResponse]
getMHLogAuditProof *connect_go.Client[api.GetLogAuditProofRequest, api.ProofResponse]
getMHLogEntries *connect_go.Client[api.GetLogEntriesRequest, api.LogEntriesResponse]
}
// GetHead calls trustix_api.v1.LogAPI.GetHead.
func (c *logAPIClient) GetHead(ctx context.Context, req *connect_go.Request[api.LogHeadRequest]) (*connect_go.Response[schema.LogHead], error) {
return c.getHead.CallUnary(ctx, req)
}
// GetLogConsistencyProof calls trustix_api.v1.LogAPI.GetLogConsistencyProof.
func (c *logAPIClient) GetLogConsistencyProof(ctx context.Context, req *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return c.getLogConsistencyProof.CallUnary(ctx, req)
}
// GetLogAuditProof calls trustix_api.v1.LogAPI.GetLogAuditProof.
func (c *logAPIClient) GetLogAuditProof(ctx context.Context, req *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return c.getLogAuditProof.CallUnary(ctx, req)
}
// GetLogEntries calls trustix_api.v1.LogAPI.GetLogEntries.
func (c *logAPIClient) GetLogEntries(ctx context.Context, req *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error) {
return c.getLogEntries.CallUnary(ctx, req)
}
// GetMapValue calls trustix_api.v1.LogAPI.GetMapValue.
func (c *logAPIClient) GetMapValue(ctx context.Context, req *connect_go.Request[api.GetMapValueRequest]) (*connect_go.Response[api.MapValueResponse], error) {
return c.getMapValue.CallUnary(ctx, req)
}
// GetMHLogConsistencyProof calls trustix_api.v1.LogAPI.GetMHLogConsistencyProof.
func (c *logAPIClient) GetMHLogConsistencyProof(ctx context.Context, req *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return c.getMHLogConsistencyProof.CallUnary(ctx, req)
}
// GetMHLogAuditProof calls trustix_api.v1.LogAPI.GetMHLogAuditProof.
func (c *logAPIClient) GetMHLogAuditProof(ctx context.Context, req *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return c.getMHLogAuditProof.CallUnary(ctx, req)
}
// GetMHLogEntries calls trustix_api.v1.LogAPI.GetMHLogEntries.
func (c *logAPIClient) GetMHLogEntries(ctx context.Context, req *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error) {
return c.getMHLogEntries.CallUnary(ctx, req)
}
// LogAPIHandler is an implementation of the trustix_api.v1.LogAPI service.
type LogAPIHandler interface {
// Get signed head
GetHead(context.Context, *connect_go.Request[api.LogHeadRequest]) (*connect_go.Response[schema.LogHead], error)
GetLogConsistencyProof(context.Context, *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetLogAuditProof(context.Context, *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetLogEntries(context.Context, *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error)
GetMapValue(context.Context, *connect_go.Request[api.GetMapValueRequest]) (*connect_go.Response[api.MapValueResponse], error)
GetMHLogConsistencyProof(context.Context, *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetMHLogAuditProof(context.Context, *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error)
GetMHLogEntries(context.Context, *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error)
}
// NewLogAPIHandler 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 NewLogAPIHandler(svc LogAPIHandler, opts ...connect_go.HandlerOption) (string, http.Handler) {
mux := http.NewServeMux()
mux.Handle("/trustix_api.v1.LogAPI/GetHead", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetHead",
svc.GetHead,
opts...,
))
mux.Handle("/trustix_api.v1.LogAPI/GetLogConsistencyProof", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetLogConsistencyProof",
svc.GetLogConsistencyProof,
opts...,
))
mux.Handle("/trustix_api.v1.LogAPI/GetLogAuditProof", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetLogAuditProof",
svc.GetLogAuditProof,
opts...,
))
mux.Handle("/trustix_api.v1.LogAPI/GetLogEntries", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetLogEntries",
svc.GetLogEntries,
opts...,
))
mux.Handle("/trustix_api.v1.LogAPI/GetMapValue", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetMapValue",
svc.GetMapValue,
opts...,
))
mux.Handle("/trustix_api.v1.LogAPI/GetMHLogConsistencyProof", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetMHLogConsistencyProof",
svc.GetMHLogConsistencyProof,
opts...,
))
mux.Handle("/trustix_api.v1.LogAPI/GetMHLogAuditProof", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetMHLogAuditProof",
svc.GetMHLogAuditProof,
opts...,
))
mux.Handle("/trustix_api.v1.LogAPI/GetMHLogEntries", connect_go.NewUnaryHandler(
"/trustix_api.v1.LogAPI/GetMHLogEntries",
svc.GetMHLogEntries,
opts...,
))
return "/trustix_api.v1.LogAPI/", mux
}
// UnimplementedLogAPIHandler returns CodeUnimplemented from all methods.
type UnimplementedLogAPIHandler struct{}
func (UnimplementedLogAPIHandler) GetHead(context.Context, *connect_go.Request[api.LogHeadRequest]) (*connect_go.Response[schema.LogHead], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetHead is not implemented"))
}
func (UnimplementedLogAPIHandler) GetLogConsistencyProof(context.Context, *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetLogConsistencyProof is not implemented"))
}
func (UnimplementedLogAPIHandler) GetLogAuditProof(context.Context, *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetLogAuditProof is not implemented"))
}
func (UnimplementedLogAPIHandler) GetLogEntries(context.Context, *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetLogEntries is not implemented"))
}
func (UnimplementedLogAPIHandler) GetMapValue(context.Context, *connect_go.Request[api.GetMapValueRequest]) (*connect_go.Response[api.MapValueResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetMapValue is not implemented"))
}
func (UnimplementedLogAPIHandler) GetMHLogConsistencyProof(context.Context, *connect_go.Request[api.GetLogConsistencyProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetMHLogConsistencyProof is not implemented"))
}
func (UnimplementedLogAPIHandler) GetMHLogAuditProof(context.Context, *connect_go.Request[api.GetLogAuditProofRequest]) (*connect_go.Response[api.ProofResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetMHLogAuditProof is not implemented"))
}
func (UnimplementedLogAPIHandler) GetMHLogEntries(context.Context, *connect_go.Request[api.GetLogEntriesRequest]) (*connect_go.Response[api.LogEntriesResponse], error) {
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("trustix_api.v1.LogAPI.GetMHLogEntries is not implemented"))
}