-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartition.connect.go
More file actions
217 lines (198 loc) · 10.3 KB
/
partition.connect.go
File metadata and controls
217 lines (198 loc) · 10.3 KB
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
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: metalstack/admin/v2/partition.proto
package adminv2connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v2 "github.com/metal-stack/api/go/metalstack/admin/v2"
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.IsAtLeastVersion1_13_0
const (
// PartitionServiceName is the fully-qualified name of the PartitionService service.
PartitionServiceName = "metalstack.admin.v2.PartitionService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// PartitionServiceCreateProcedure is the fully-qualified name of the PartitionService's Create RPC.
PartitionServiceCreateProcedure = "/metalstack.admin.v2.PartitionService/Create"
// PartitionServiceUpdateProcedure is the fully-qualified name of the PartitionService's Update RPC.
PartitionServiceUpdateProcedure = "/metalstack.admin.v2.PartitionService/Update"
// PartitionServiceDeleteProcedure is the fully-qualified name of the PartitionService's Delete RPC.
PartitionServiceDeleteProcedure = "/metalstack.admin.v2.PartitionService/Delete"
// PartitionServiceCapacityProcedure is the fully-qualified name of the PartitionService's Capacity
// RPC.
PartitionServiceCapacityProcedure = "/metalstack.admin.v2.PartitionService/Capacity"
)
// PartitionServiceClient is a client for the metalstack.admin.v2.PartitionService service.
type PartitionServiceClient interface {
// Creates a new partition.
Create(context.Context, *v2.PartitionServiceCreateRequest) (*v2.PartitionServiceCreateResponse, error)
// Updates a partition.
Update(context.Context, *v2.PartitionServiceUpdateRequest) (*v2.PartitionServiceUpdateResponse, error)
// Deletes a partition.
Delete(context.Context, *v2.PartitionServiceDeleteRequest) (*v2.PartitionServiceDeleteResponse, error)
// Returns the capacity of a partition.
Capacity(context.Context, *v2.PartitionServiceCapacityRequest) (*v2.PartitionServiceCapacityResponse, error)
}
// NewPartitionServiceClient constructs a client for the metalstack.admin.v2.PartitionService
// 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 NewPartitionServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) PartitionServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
partitionServiceMethods := v2.File_metalstack_admin_v2_partition_proto.Services().ByName("PartitionService").Methods()
return &partitionServiceClient{
create: connect.NewClient[v2.PartitionServiceCreateRequest, v2.PartitionServiceCreateResponse](
httpClient,
baseURL+PartitionServiceCreateProcedure,
connect.WithSchema(partitionServiceMethods.ByName("Create")),
connect.WithClientOptions(opts...),
),
update: connect.NewClient[v2.PartitionServiceUpdateRequest, v2.PartitionServiceUpdateResponse](
httpClient,
baseURL+PartitionServiceUpdateProcedure,
connect.WithSchema(partitionServiceMethods.ByName("Update")),
connect.WithClientOptions(opts...),
),
delete: connect.NewClient[v2.PartitionServiceDeleteRequest, v2.PartitionServiceDeleteResponse](
httpClient,
baseURL+PartitionServiceDeleteProcedure,
connect.WithSchema(partitionServiceMethods.ByName("Delete")),
connect.WithClientOptions(opts...),
),
capacity: connect.NewClient[v2.PartitionServiceCapacityRequest, v2.PartitionServiceCapacityResponse](
httpClient,
baseURL+PartitionServiceCapacityProcedure,
connect.WithSchema(partitionServiceMethods.ByName("Capacity")),
connect.WithClientOptions(opts...),
),
}
}
// partitionServiceClient implements PartitionServiceClient.
type partitionServiceClient struct {
create *connect.Client[v2.PartitionServiceCreateRequest, v2.PartitionServiceCreateResponse]
update *connect.Client[v2.PartitionServiceUpdateRequest, v2.PartitionServiceUpdateResponse]
delete *connect.Client[v2.PartitionServiceDeleteRequest, v2.PartitionServiceDeleteResponse]
capacity *connect.Client[v2.PartitionServiceCapacityRequest, v2.PartitionServiceCapacityResponse]
}
// Create calls metalstack.admin.v2.PartitionService.Create.
func (c *partitionServiceClient) Create(ctx context.Context, req *v2.PartitionServiceCreateRequest) (*v2.PartitionServiceCreateResponse, error) {
response, err := c.create.CallUnary(ctx, connect.NewRequest(req))
if response != nil {
return response.Msg, err
}
return nil, err
}
// Update calls metalstack.admin.v2.PartitionService.Update.
func (c *partitionServiceClient) Update(ctx context.Context, req *v2.PartitionServiceUpdateRequest) (*v2.PartitionServiceUpdateResponse, error) {
response, err := c.update.CallUnary(ctx, connect.NewRequest(req))
if response != nil {
return response.Msg, err
}
return nil, err
}
// Delete calls metalstack.admin.v2.PartitionService.Delete.
func (c *partitionServiceClient) Delete(ctx context.Context, req *v2.PartitionServiceDeleteRequest) (*v2.PartitionServiceDeleteResponse, error) {
response, err := c.delete.CallUnary(ctx, connect.NewRequest(req))
if response != nil {
return response.Msg, err
}
return nil, err
}
// Capacity calls metalstack.admin.v2.PartitionService.Capacity.
func (c *partitionServiceClient) Capacity(ctx context.Context, req *v2.PartitionServiceCapacityRequest) (*v2.PartitionServiceCapacityResponse, error) {
response, err := c.capacity.CallUnary(ctx, connect.NewRequest(req))
if response != nil {
return response.Msg, err
}
return nil, err
}
// PartitionServiceHandler is an implementation of the metalstack.admin.v2.PartitionService service.
type PartitionServiceHandler interface {
// Creates a new partition.
Create(context.Context, *v2.PartitionServiceCreateRequest) (*v2.PartitionServiceCreateResponse, error)
// Updates a partition.
Update(context.Context, *v2.PartitionServiceUpdateRequest) (*v2.PartitionServiceUpdateResponse, error)
// Deletes a partition.
Delete(context.Context, *v2.PartitionServiceDeleteRequest) (*v2.PartitionServiceDeleteResponse, error)
// Returns the capacity of a partition.
Capacity(context.Context, *v2.PartitionServiceCapacityRequest) (*v2.PartitionServiceCapacityResponse, error)
}
// NewPartitionServiceHandler 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 NewPartitionServiceHandler(svc PartitionServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
partitionServiceMethods := v2.File_metalstack_admin_v2_partition_proto.Services().ByName("PartitionService").Methods()
partitionServiceCreateHandler := connect.NewUnaryHandlerSimple(
PartitionServiceCreateProcedure,
svc.Create,
connect.WithSchema(partitionServiceMethods.ByName("Create")),
connect.WithHandlerOptions(opts...),
)
partitionServiceUpdateHandler := connect.NewUnaryHandlerSimple(
PartitionServiceUpdateProcedure,
svc.Update,
connect.WithSchema(partitionServiceMethods.ByName("Update")),
connect.WithHandlerOptions(opts...),
)
partitionServiceDeleteHandler := connect.NewUnaryHandlerSimple(
PartitionServiceDeleteProcedure,
svc.Delete,
connect.WithSchema(partitionServiceMethods.ByName("Delete")),
connect.WithHandlerOptions(opts...),
)
partitionServiceCapacityHandler := connect.NewUnaryHandlerSimple(
PartitionServiceCapacityProcedure,
svc.Capacity,
connect.WithSchema(partitionServiceMethods.ByName("Capacity")),
connect.WithHandlerOptions(opts...),
)
return "/metalstack.admin.v2.PartitionService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case PartitionServiceCreateProcedure:
partitionServiceCreateHandler.ServeHTTP(w, r)
case PartitionServiceUpdateProcedure:
partitionServiceUpdateHandler.ServeHTTP(w, r)
case PartitionServiceDeleteProcedure:
partitionServiceDeleteHandler.ServeHTTP(w, r)
case PartitionServiceCapacityProcedure:
partitionServiceCapacityHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedPartitionServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedPartitionServiceHandler struct{}
func (UnimplementedPartitionServiceHandler) Create(context.Context, *v2.PartitionServiceCreateRequest) (*v2.PartitionServiceCreateResponse, error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("metalstack.admin.v2.PartitionService.Create is not implemented"))
}
func (UnimplementedPartitionServiceHandler) Update(context.Context, *v2.PartitionServiceUpdateRequest) (*v2.PartitionServiceUpdateResponse, error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("metalstack.admin.v2.PartitionService.Update is not implemented"))
}
func (UnimplementedPartitionServiceHandler) Delete(context.Context, *v2.PartitionServiceDeleteRequest) (*v2.PartitionServiceDeleteResponse, error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("metalstack.admin.v2.PartitionService.Delete is not implemented"))
}
func (UnimplementedPartitionServiceHandler) Capacity(context.Context, *v2.PartitionServiceCapacityRequest) (*v2.PartitionServiceCapacityResponse, error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("metalstack.admin.v2.PartitionService.Capacity is not implemented"))
}