1// SPDX-License-Identifier: MIT
2
3// Code generated by protoc-gen-connect-go. DO NOT EDIT.
4//
5// Source: ermite/repo.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 // RepoServiceName is the fully-qualified name of the RepoService service.
27 RepoServiceName = "ermite.RepoService"
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 // RepoServiceListReposProcedure is the fully-qualified name of the RepoService's ListRepos RPC.
39 RepoServiceListReposProcedure = "/ermite.RepoService/ListRepos"
40 // RepoServiceGetRepoProcedure is the fully-qualified name of the RepoService's GetRepo RPC.
41 RepoServiceGetRepoProcedure = "/ermite.RepoService/GetRepo"
42 // RepoServiceCreateRepoProcedure is the fully-qualified name of the RepoService's CreateRepo RPC.
43 RepoServiceCreateRepoProcedure = "/ermite.RepoService/CreateRepo"
44 // RepoServiceUpdateRepoProcedure is the fully-qualified name of the RepoService's UpdateRepo RPC.
45 RepoServiceUpdateRepoProcedure = "/ermite.RepoService/UpdateRepo"
46 // RepoServiceDeleteRepoProcedure is the fully-qualified name of the RepoService's DeleteRepo RPC.
47 RepoServiceDeleteRepoProcedure = "/ermite.RepoService/DeleteRepo"
48)
49
50// RepoServiceClient is a client for the ermite.RepoService service.
51type RepoServiceClient interface {
52 // ListRepos lists the repositories the caller may see, ordered by name.
53 ListRepos(context.Context, *connect.Request[ermite.ListReposRequest]) (*connect.Response[ermite.ListReposResponse], error)
54 // GetRepo returns one repository. Fails with not_found if it does not exist
55 // or is private and not readable by the caller.
56 GetRepo(context.Context, *connect.Request[ermite.GetRepoRequest]) (*connect.Response[ermite.GetRepoResponse], error)
57 // CreateRepo creates an empty repository with the default settings. Needs
58 // the repo:write scope. Fails
59 // with already_exists if the name is taken and invalid_argument if the name
60 // is not valid.
61 CreateRepo(context.Context, *connect.Request[ermite.CreateRepoRequest]) (*connect.Response[ermite.CreateRepoResponse], error)
62 // UpdateRepo changes the fields named in update_mask, including the merge
63 // settings. Needs the repo:admin scope.
64 UpdateRepo(context.Context, *connect.Request[ermite.UpdateRepoRequest]) (*connect.Response[ermite.UpdateRepoResponse], error)
65 // DeleteRepo deletes a repository. Needs the repo:admin scope. The server
66 // moves the data aside rather than destroying it; there is no undelete RPC.
67 DeleteRepo(context.Context, *connect.Request[ermite.DeleteRepoRequest]) (*connect.Response[ermite.DeleteRepoResponse], error)
68}
69
70// NewRepoServiceClient constructs a client for the ermite.RepoService service. By default, it uses
71// the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
72// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
73// connect.WithGRPCWeb() options.
74//
75// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
76// http://api.acme.com or https://acme.com/grpc).
77func NewRepoServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) RepoServiceClient {
78 baseURL = strings.TrimRight(baseURL, "/")
79 repoServiceMethods := ermite.File_ermite_repo_proto.Services().ByName("RepoService").Methods()
80 return &repoServiceClient{
81 listRepos: connect.NewClient[ermite.ListReposRequest, ermite.ListReposResponse](
82 httpClient,
83 baseURL+RepoServiceListReposProcedure,
84 connect.WithSchema(repoServiceMethods.ByName("ListRepos")),
85 connect.WithClientOptions(opts...),
86 ),
87 getRepo: connect.NewClient[ermite.GetRepoRequest, ermite.GetRepoResponse](
88 httpClient,
89 baseURL+RepoServiceGetRepoProcedure,
90 connect.WithSchema(repoServiceMethods.ByName("GetRepo")),
91 connect.WithClientOptions(opts...),
92 ),
93 createRepo: connect.NewClient[ermite.CreateRepoRequest, ermite.CreateRepoResponse](
94 httpClient,
95 baseURL+RepoServiceCreateRepoProcedure,
96 connect.WithSchema(repoServiceMethods.ByName("CreateRepo")),
97 connect.WithClientOptions(opts...),
98 ),
99 updateRepo: connect.NewClient[ermite.UpdateRepoRequest, ermite.UpdateRepoResponse](
100 httpClient,
101 baseURL+RepoServiceUpdateRepoProcedure,
102 connect.WithSchema(repoServiceMethods.ByName("UpdateRepo")),
103 connect.WithClientOptions(opts...),
104 ),
105 deleteRepo: connect.NewClient[ermite.DeleteRepoRequest, ermite.DeleteRepoResponse](
106 httpClient,
107 baseURL+RepoServiceDeleteRepoProcedure,
108 connect.WithSchema(repoServiceMethods.ByName("DeleteRepo")),
109 connect.WithClientOptions(opts...),
110 ),
111 }
112}
113
114// repoServiceClient implements RepoServiceClient.
115type repoServiceClient struct {
116 listRepos *connect.Client[ermite.ListReposRequest, ermite.ListReposResponse]
117 getRepo *connect.Client[ermite.GetRepoRequest, ermite.GetRepoResponse]
118 createRepo *connect.Client[ermite.CreateRepoRequest, ermite.CreateRepoResponse]
119 updateRepo *connect.Client[ermite.UpdateRepoRequest, ermite.UpdateRepoResponse]
120 deleteRepo *connect.Client[ermite.DeleteRepoRequest, ermite.DeleteRepoResponse]
121}
122
123// ListRepos calls ermite.RepoService.ListRepos.
124func (c *repoServiceClient) ListRepos(ctx context.Context, req *connect.Request[ermite.ListReposRequest]) (*connect.Response[ermite.ListReposResponse], error) {
125 return c.listRepos.CallUnary(ctx, req)
126}
127
128// GetRepo calls ermite.RepoService.GetRepo.
129func (c *repoServiceClient) GetRepo(ctx context.Context, req *connect.Request[ermite.GetRepoRequest]) (*connect.Response[ermite.GetRepoResponse], error) {
130 return c.getRepo.CallUnary(ctx, req)
131}
132
133// CreateRepo calls ermite.RepoService.CreateRepo.
134func (c *repoServiceClient) CreateRepo(ctx context.Context, req *connect.Request[ermite.CreateRepoRequest]) (*connect.Response[ermite.CreateRepoResponse], error) {
135 return c.createRepo.CallUnary(ctx, req)
136}
137
138// UpdateRepo calls ermite.RepoService.UpdateRepo.
139func (c *repoServiceClient) UpdateRepo(ctx context.Context, req *connect.Request[ermite.UpdateRepoRequest]) (*connect.Response[ermite.UpdateRepoResponse], error) {
140 return c.updateRepo.CallUnary(ctx, req)
141}
142
143// DeleteRepo calls ermite.RepoService.DeleteRepo.
144func (c *repoServiceClient) DeleteRepo(ctx context.Context, req *connect.Request[ermite.DeleteRepoRequest]) (*connect.Response[ermite.DeleteRepoResponse], error) {
145 return c.deleteRepo.CallUnary(ctx, req)
146}
147
148// RepoServiceHandler is an implementation of the ermite.RepoService service.
149type RepoServiceHandler interface {
150 // ListRepos lists the repositories the caller may see, ordered by name.
151 ListRepos(context.Context, *connect.Request[ermite.ListReposRequest]) (*connect.Response[ermite.ListReposResponse], error)
152 // GetRepo returns one repository. Fails with not_found if it does not exist
153 // or is private and not readable by the caller.
154 GetRepo(context.Context, *connect.Request[ermite.GetRepoRequest]) (*connect.Response[ermite.GetRepoResponse], error)
155 // CreateRepo creates an empty repository with the default settings. Needs
156 // the repo:write scope. Fails
157 // with already_exists if the name is taken and invalid_argument if the name
158 // is not valid.
159 CreateRepo(context.Context, *connect.Request[ermite.CreateRepoRequest]) (*connect.Response[ermite.CreateRepoResponse], error)
160 // UpdateRepo changes the fields named in update_mask, including the merge
161 // settings. Needs the repo:admin scope.
162 UpdateRepo(context.Context, *connect.Request[ermite.UpdateRepoRequest]) (*connect.Response[ermite.UpdateRepoResponse], error)
163 // DeleteRepo deletes a repository. Needs the repo:admin scope. The server
164 // moves the data aside rather than destroying it; there is no undelete RPC.
165 DeleteRepo(context.Context, *connect.Request[ermite.DeleteRepoRequest]) (*connect.Response[ermite.DeleteRepoResponse], error)
166}
167
168// NewRepoServiceHandler builds an HTTP handler from the service implementation. It returns the path
169// on which to mount the handler and the handler itself.
170//
171// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
172// and JSON codecs. They also support gzip compression.
173func NewRepoServiceHandler(svc RepoServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
174 repoServiceMethods := ermite.File_ermite_repo_proto.Services().ByName("RepoService").Methods()
175 repoServiceListReposHandler := connect.NewUnaryHandler(
176 RepoServiceListReposProcedure,
177 svc.ListRepos,
178 connect.WithSchema(repoServiceMethods.ByName("ListRepos")),
179 connect.WithHandlerOptions(opts...),
180 )
181 repoServiceGetRepoHandler := connect.NewUnaryHandler(
182 RepoServiceGetRepoProcedure,
183 svc.GetRepo,
184 connect.WithSchema(repoServiceMethods.ByName("GetRepo")),
185 connect.WithHandlerOptions(opts...),
186 )
187 repoServiceCreateRepoHandler := connect.NewUnaryHandler(
188 RepoServiceCreateRepoProcedure,
189 svc.CreateRepo,
190 connect.WithSchema(repoServiceMethods.ByName("CreateRepo")),
191 connect.WithHandlerOptions(opts...),
192 )
193 repoServiceUpdateRepoHandler := connect.NewUnaryHandler(
194 RepoServiceUpdateRepoProcedure,
195 svc.UpdateRepo,
196 connect.WithSchema(repoServiceMethods.ByName("UpdateRepo")),
197 connect.WithHandlerOptions(opts...),
198 )
199 repoServiceDeleteRepoHandler := connect.NewUnaryHandler(
200 RepoServiceDeleteRepoProcedure,
201 svc.DeleteRepo,
202 connect.WithSchema(repoServiceMethods.ByName("DeleteRepo")),
203 connect.WithHandlerOptions(opts...),
204 )
205 return "/ermite.RepoService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
206 switch r.URL.Path {
207 case RepoServiceListReposProcedure:
208 repoServiceListReposHandler.ServeHTTP(w, r)
209 case RepoServiceGetRepoProcedure:
210 repoServiceGetRepoHandler.ServeHTTP(w, r)
211 case RepoServiceCreateRepoProcedure:
212 repoServiceCreateRepoHandler.ServeHTTP(w, r)
213 case RepoServiceUpdateRepoProcedure:
214 repoServiceUpdateRepoHandler.ServeHTTP(w, r)
215 case RepoServiceDeleteRepoProcedure:
216 repoServiceDeleteRepoHandler.ServeHTTP(w, r)
217 default:
218 http.NotFound(w, r)
219 }
220 })
221}
222
223// UnimplementedRepoServiceHandler returns CodeUnimplemented from all methods.
224type UnimplementedRepoServiceHandler struct{}
225
226func (UnimplementedRepoServiceHandler) ListRepos(context.Context, *connect.Request[ermite.ListReposRequest]) (*connect.Response[ermite.ListReposResponse], error) {
227 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.RepoService.ListRepos is not implemented"))
228}
229
230func (UnimplementedRepoServiceHandler) GetRepo(context.Context, *connect.Request[ermite.GetRepoRequest]) (*connect.Response[ermite.GetRepoResponse], error) {
231 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.RepoService.GetRepo is not implemented"))
232}
233
234func (UnimplementedRepoServiceHandler) CreateRepo(context.Context, *connect.Request[ermite.CreateRepoRequest]) (*connect.Response[ermite.CreateRepoResponse], error) {
235 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.RepoService.CreateRepo is not implemented"))
236}
237
238func (UnimplementedRepoServiceHandler) UpdateRepo(context.Context, *connect.Request[ermite.UpdateRepoRequest]) (*connect.Response[ermite.UpdateRepoResponse], error) {
239 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.RepoService.UpdateRepo is not implemented"))
240}
241
242func (UnimplementedRepoServiceHandler) DeleteRepo(context.Context, *connect.Request[ermite.DeleteRepoRequest]) (*connect.Response[ermite.DeleteRepoResponse], error) {
243 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.RepoService.DeleteRepo is not implemented"))
244}