This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
runtime.http.pb.go
180 lines (171 loc) · 5.75 KB
/
runtime.http.pb.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
// Code generated by protoc-gen-go-http. DO NOT EDIT.
// Source: runtime.proto
package pb
import (
context "context"
http1 "net/http"
strings "strings"
transport "github.com/erda-project/erda-infra/pkg/transport"
http "github.com/erda-project/erda-infra/pkg/transport/http"
httprule "github.com/erda-project/erda-infra/pkg/transport/http/httprule"
runtime "github.com/erda-project/erda-infra/pkg/transport/http/runtime"
urlenc "github.com/erda-project/erda-infra/pkg/urlenc"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the "github.com/erda-project/erda-infra/pkg/transport/http" package it is being compiled against.
const _ = http.SupportPackageIsVersion1
// RuntimeServiceHandler is the server API for RuntimeService service.
type RuntimeServiceHandler interface {
// GET /api/runtimes/{nameOrID}
GetRuntime(context.Context, *GetRuntimeRequest) (*RuntimeInspect, error)
// DELETE /api/runtimes/{id}
DelRuntime(context.Context, *DelRuntimeRequest) (*Runtime, error)
}
// RegisterRuntimeServiceHandler register RuntimeServiceHandler to http.Router.
func RegisterRuntimeServiceHandler(r http.Router, srv RuntimeServiceHandler, opts ...http.HandleOption) {
h := http.DefaultHandleOptions()
for _, op := range opts {
op(h)
}
encodeFunc := func(fn func(http1.ResponseWriter, *http1.Request) (interface{}, error)) http.HandlerFunc {
handler := func(w http1.ResponseWriter, r *http1.Request) {
out, err := fn(w, r)
if err != nil {
h.Error(w, r, err)
return
}
if err := h.Encode(w, r, out); err != nil {
h.Error(w, r, err)
}
}
if h.HTTPInterceptor != nil {
handler = h.HTTPInterceptor(handler)
}
return handler
}
add_GetRuntime := func(method, path string, fn func(context.Context, *GetRuntimeRequest) (*RuntimeInspect, error)) {
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return fn(ctx, req.(*GetRuntimeRequest))
}
var GetRuntime_info transport.ServiceInfo
if h.Interceptor != nil {
GetRuntime_info = transport.NewServiceInfo("erda.orchestrator.runtime.RuntimeService", "GetRuntime", srv)
handler = h.Interceptor(handler)
}
compiler, _ := httprule.Parse(path)
temp := compiler.Compile()
pattern, _ := runtime.NewPattern(httprule.SupportPackageIsVersion1, temp.OpCodes, temp.Pool, temp.Verb)
r.Add(method, path, encodeFunc(
func(w http1.ResponseWriter, r *http1.Request) (interface{}, error) {
ctx := http.WithRequest(r.Context(), r)
ctx = transport.WithHTTPHeaderForServer(ctx, r.Header)
if h.Interceptor != nil {
ctx = context.WithValue(ctx, transport.ServiceInfoContextKey, GetRuntime_info)
}
r = r.WithContext(ctx)
var in GetRuntimeRequest
if err := h.Decode(r, &in); err != nil {
return nil, err
}
var input interface{} = &in
if u, ok := (input).(urlenc.URLValuesUnmarshaler); ok {
if err := u.UnmarshalURLValues("", r.URL.Query()); err != nil {
return nil, err
}
}
params := r.URL.Query()
if vals := params["applicationId"]; len(vals) > 0 {
in.AppID = vals[0]
}
if vals := params["workspace"]; len(vals) > 0 {
in.Workspace = vals[0]
}
path := r.URL.Path
if len(path) > 0 {
components := strings.Split(path[1:], "/")
last := len(components) - 1
var verb string
if idx := strings.LastIndex(components[last], ":"); idx >= 0 {
c := components[last]
components[last], verb = c[:idx], c[idx+1:]
}
vars, err := pattern.Match(components, verb)
if err != nil {
return nil, err
}
for k, val := range vars {
switch k {
case "nameOrID":
in.NameOrID = val
}
}
}
out, err := handler(ctx, &in)
if err != nil {
return out, err
}
return out, nil
}),
)
}
add_DelRuntime := func(method, path string, fn func(context.Context, *DelRuntimeRequest) (*Runtime, error)) {
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return fn(ctx, req.(*DelRuntimeRequest))
}
var DelRuntime_info transport.ServiceInfo
if h.Interceptor != nil {
DelRuntime_info = transport.NewServiceInfo("erda.orchestrator.runtime.RuntimeService", "DelRuntime", srv)
handler = h.Interceptor(handler)
}
compiler, _ := httprule.Parse(path)
temp := compiler.Compile()
pattern, _ := runtime.NewPattern(httprule.SupportPackageIsVersion1, temp.OpCodes, temp.Pool, temp.Verb)
r.Add(method, path, encodeFunc(
func(w http1.ResponseWriter, r *http1.Request) (interface{}, error) {
ctx := http.WithRequest(r.Context(), r)
ctx = transport.WithHTTPHeaderForServer(ctx, r.Header)
if h.Interceptor != nil {
ctx = context.WithValue(ctx, transport.ServiceInfoContextKey, DelRuntime_info)
}
r = r.WithContext(ctx)
var in DelRuntimeRequest
if err := h.Decode(r, &in); err != nil {
return nil, err
}
var input interface{} = &in
if u, ok := (input).(urlenc.URLValuesUnmarshaler); ok {
if err := u.UnmarshalURLValues("", r.URL.Query()); err != nil {
return nil, err
}
}
path := r.URL.Path
if len(path) > 0 {
components := strings.Split(path[1:], "/")
last := len(components) - 1
var verb string
if idx := strings.LastIndex(components[last], ":"); idx >= 0 {
c := components[last]
components[last], verb = c[:idx], c[idx+1:]
}
vars, err := pattern.Match(components, verb)
if err != nil {
return nil, err
}
for k, val := range vars {
switch k {
case "id":
in.Id = val
}
}
}
out, err := handler(ctx, &in)
if err != nil {
return out, err
}
return out, nil
}),
)
}
add_GetRuntime("GET", "/api/runtimes/{nameOrID}", srv.GetRuntime)
add_DelRuntime("DELETE", "/api/runtimes/{id}", srv.DelRuntime)
}