1// SPDX-License-Identifier: MIT
2
3// Code generated by protoc-gen-connect-go. DO NOT EDIT.
4//
5// Source: ermite/signature.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 // TrustedKeyServiceName is the fully-qualified name of the TrustedKeyService service.
27 TrustedKeyServiceName = "ermite.TrustedKeyService"
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 // TrustedKeyServiceListTrustedKeysProcedure is the fully-qualified name of the TrustedKeyService's
39 // ListTrustedKeys RPC.
40 TrustedKeyServiceListTrustedKeysProcedure = "/ermite.TrustedKeyService/ListTrustedKeys"
41 // TrustedKeyServiceAddTrustedKeyProcedure is the fully-qualified name of the TrustedKeyService's
42 // AddTrustedKey RPC.
43 TrustedKeyServiceAddTrustedKeyProcedure = "/ermite.TrustedKeyService/AddTrustedKey"
44 // TrustedKeyServiceRemoveTrustedKeyProcedure is the fully-qualified name of the TrustedKeyService's
45 // RemoveTrustedKey RPC.
46 TrustedKeyServiceRemoveTrustedKeyProcedure = "/ermite.TrustedKeyService/RemoveTrustedKey"
47)
48
49// TrustedKeyServiceClient is a client for the ermite.TrustedKeyService service.
50type TrustedKeyServiceClient interface {
51 // ListTrustedKeys lists the keys, the builtin key first. Any authenticated
52 // caller may.
53 ListTrustedKeys(context.Context, *connect.Request[ermite.ListTrustedKeysRequest]) (*connect.Response[ermite.ListTrustedKeysResponse], error)
54 // AddTrustedKey adds a key. Owner only. invalid_argument for a key that
55 // does not parse, a private key, no or too many emails; already_exists for
56 // a key already listed; resource_exhausted beyond 100 keys.
57 AddTrustedKey(context.Context, *connect.Request[ermite.AddTrustedKeyRequest]) (*connect.Response[ermite.AddTrustedKeyResponse], error)
58 // RemoveTrustedKey removes a key. Owner only. not_found for an unknown id;
59 // failed_precondition for the builtin key.
60 RemoveTrustedKey(context.Context, *connect.Request[ermite.RemoveTrustedKeyRequest]) (*connect.Response[ermite.RemoveTrustedKeyResponse], error)
61}
62
63// NewTrustedKeyServiceClient constructs a client for the ermite.TrustedKeyService service. By
64// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
65// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
66// connect.WithGRPC() or connect.WithGRPCWeb() options.
67//
68// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
69// http://api.acme.com or https://acme.com/grpc).
70func NewTrustedKeyServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) TrustedKeyServiceClient {
71 baseURL = strings.TrimRight(baseURL, "/")
72 trustedKeyServiceMethods := ermite.File_ermite_signature_proto.Services().ByName("TrustedKeyService").Methods()
73 return &trustedKeyServiceClient{
74 listTrustedKeys: connect.NewClient[ermite.ListTrustedKeysRequest, ermite.ListTrustedKeysResponse](
75 httpClient,
76 baseURL+TrustedKeyServiceListTrustedKeysProcedure,
77 connect.WithSchema(trustedKeyServiceMethods.ByName("ListTrustedKeys")),
78 connect.WithClientOptions(opts...),
79 ),
80 addTrustedKey: connect.NewClient[ermite.AddTrustedKeyRequest, ermite.AddTrustedKeyResponse](
81 httpClient,
82 baseURL+TrustedKeyServiceAddTrustedKeyProcedure,
83 connect.WithSchema(trustedKeyServiceMethods.ByName("AddTrustedKey")),
84 connect.WithClientOptions(opts...),
85 ),
86 removeTrustedKey: connect.NewClient[ermite.RemoveTrustedKeyRequest, ermite.RemoveTrustedKeyResponse](
87 httpClient,
88 baseURL+TrustedKeyServiceRemoveTrustedKeyProcedure,
89 connect.WithSchema(trustedKeyServiceMethods.ByName("RemoveTrustedKey")),
90 connect.WithClientOptions(opts...),
91 ),
92 }
93}
94
95// trustedKeyServiceClient implements TrustedKeyServiceClient.
96type trustedKeyServiceClient struct {
97 listTrustedKeys *connect.Client[ermite.ListTrustedKeysRequest, ermite.ListTrustedKeysResponse]
98 addTrustedKey *connect.Client[ermite.AddTrustedKeyRequest, ermite.AddTrustedKeyResponse]
99 removeTrustedKey *connect.Client[ermite.RemoveTrustedKeyRequest, ermite.RemoveTrustedKeyResponse]
100}
101
102// ListTrustedKeys calls ermite.TrustedKeyService.ListTrustedKeys.
103func (c *trustedKeyServiceClient) ListTrustedKeys(ctx context.Context, req *connect.Request[ermite.ListTrustedKeysRequest]) (*connect.Response[ermite.ListTrustedKeysResponse], error) {
104 return c.listTrustedKeys.CallUnary(ctx, req)
105}
106
107// AddTrustedKey calls ermite.TrustedKeyService.AddTrustedKey.
108func (c *trustedKeyServiceClient) AddTrustedKey(ctx context.Context, req *connect.Request[ermite.AddTrustedKeyRequest]) (*connect.Response[ermite.AddTrustedKeyResponse], error) {
109 return c.addTrustedKey.CallUnary(ctx, req)
110}
111
112// RemoveTrustedKey calls ermite.TrustedKeyService.RemoveTrustedKey.
113func (c *trustedKeyServiceClient) RemoveTrustedKey(ctx context.Context, req *connect.Request[ermite.RemoveTrustedKeyRequest]) (*connect.Response[ermite.RemoveTrustedKeyResponse], error) {
114 return c.removeTrustedKey.CallUnary(ctx, req)
115}
116
117// TrustedKeyServiceHandler is an implementation of the ermite.TrustedKeyService service.
118type TrustedKeyServiceHandler interface {
119 // ListTrustedKeys lists the keys, the builtin key first. Any authenticated
120 // caller may.
121 ListTrustedKeys(context.Context, *connect.Request[ermite.ListTrustedKeysRequest]) (*connect.Response[ermite.ListTrustedKeysResponse], error)
122 // AddTrustedKey adds a key. Owner only. invalid_argument for a key that
123 // does not parse, a private key, no or too many emails; already_exists for
124 // a key already listed; resource_exhausted beyond 100 keys.
125 AddTrustedKey(context.Context, *connect.Request[ermite.AddTrustedKeyRequest]) (*connect.Response[ermite.AddTrustedKeyResponse], error)
126 // RemoveTrustedKey removes a key. Owner only. not_found for an unknown id;
127 // failed_precondition for the builtin key.
128 RemoveTrustedKey(context.Context, *connect.Request[ermite.RemoveTrustedKeyRequest]) (*connect.Response[ermite.RemoveTrustedKeyResponse], error)
129}
130
131// NewTrustedKeyServiceHandler builds an HTTP handler from the service implementation. It returns
132// the path on which to mount the handler and the handler itself.
133//
134// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
135// and JSON codecs. They also support gzip compression.
136func NewTrustedKeyServiceHandler(svc TrustedKeyServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
137 trustedKeyServiceMethods := ermite.File_ermite_signature_proto.Services().ByName("TrustedKeyService").Methods()
138 trustedKeyServiceListTrustedKeysHandler := connect.NewUnaryHandler(
139 TrustedKeyServiceListTrustedKeysProcedure,
140 svc.ListTrustedKeys,
141 connect.WithSchema(trustedKeyServiceMethods.ByName("ListTrustedKeys")),
142 connect.WithHandlerOptions(opts...),
143 )
144 trustedKeyServiceAddTrustedKeyHandler := connect.NewUnaryHandler(
145 TrustedKeyServiceAddTrustedKeyProcedure,
146 svc.AddTrustedKey,
147 connect.WithSchema(trustedKeyServiceMethods.ByName("AddTrustedKey")),
148 connect.WithHandlerOptions(opts...),
149 )
150 trustedKeyServiceRemoveTrustedKeyHandler := connect.NewUnaryHandler(
151 TrustedKeyServiceRemoveTrustedKeyProcedure,
152 svc.RemoveTrustedKey,
153 connect.WithSchema(trustedKeyServiceMethods.ByName("RemoveTrustedKey")),
154 connect.WithHandlerOptions(opts...),
155 )
156 return "/ermite.TrustedKeyService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
157 switch r.URL.Path {
158 case TrustedKeyServiceListTrustedKeysProcedure:
159 trustedKeyServiceListTrustedKeysHandler.ServeHTTP(w, r)
160 case TrustedKeyServiceAddTrustedKeyProcedure:
161 trustedKeyServiceAddTrustedKeyHandler.ServeHTTP(w, r)
162 case TrustedKeyServiceRemoveTrustedKeyProcedure:
163 trustedKeyServiceRemoveTrustedKeyHandler.ServeHTTP(w, r)
164 default:
165 http.NotFound(w, r)
166 }
167 })
168}
169
170// UnimplementedTrustedKeyServiceHandler returns CodeUnimplemented from all methods.
171type UnimplementedTrustedKeyServiceHandler struct{}
172
173func (UnimplementedTrustedKeyServiceHandler) ListTrustedKeys(context.Context, *connect.Request[ermite.ListTrustedKeysRequest]) (*connect.Response[ermite.ListTrustedKeysResponse], error) {
174 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.TrustedKeyService.ListTrustedKeys is not implemented"))
175}
176
177func (UnimplementedTrustedKeyServiceHandler) AddTrustedKey(context.Context, *connect.Request[ermite.AddTrustedKeyRequest]) (*connect.Response[ermite.AddTrustedKeyResponse], error) {
178 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.TrustedKeyService.AddTrustedKey is not implemented"))
179}
180
181func (UnimplementedTrustedKeyServiceHandler) RemoveTrustedKey(context.Context, *connect.Request[ermite.RemoveTrustedKeyRequest]) (*connect.Response[ermite.RemoveTrustedKeyResponse], error) {
182 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.TrustedKeyService.RemoveTrustedKey is not implemented"))
183}