@daocloud-proto/mcamel-rabbitmq 0.4.0-11 → 0.4.0-113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cluster.pb.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
5
  */
6
6
 
7
- import * as fm from "../../v1alpha1/ts_out/api"
7
+ import * as CommonCommon from "./common.pb"
8
+ import * as fm from "./fetch.pb"
8
9
 
9
10
  export enum GetClusterListRespGetClusterListDataClusterPhase {
10
11
  CLUSTER_PHASE_UNSPECIFIED = "CLUSTER_PHASE_UNSPECIFIED",
@@ -25,7 +26,8 @@ export type GetClusterListRespGetClusterListData = {
25
26
  }
26
27
 
27
28
  export type GetClusterListResp = {
28
- data?: GetClusterListRespGetClusterListData[]
29
+ items?: GetClusterListRespGetClusterListData[]
30
+ pagination?: CommonCommon.Pagination
29
31
  }
30
32
 
31
33
  export type GetClusterNamespaceListReq = {
@@ -33,7 +35,8 @@ export type GetClusterNamespaceListReq = {
33
35
  }
34
36
 
35
37
  export type GetClusterNamespaceListResp = {
36
- data?: string[]
38
+ items?: string[]
39
+ pagination?: CommonCommon.Pagination
37
40
  }
38
41
 
39
42
  export class Cluster {
package/common.pb.ts ADDED
@@ -0,0 +1,24 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /*
4
+ * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
+ */
6
+
7
+ export enum PageInfoReqSortDir {
8
+ ASC = "ASC",
9
+ DESC = "DESC",
10
+ }
11
+
12
+ export type Pagination = {
13
+ total?: number
14
+ page?: number
15
+ pageSize?: number
16
+ pages?: number
17
+ }
18
+
19
+ export type PageInfoReq = {
20
+ page?: number
21
+ pageSize?: number
22
+ sortDir?: PageInfoReqSortDir
23
+ sortBy?: string
24
+ }
package/fetch.pb.ts ADDED
@@ -0,0 +1,232 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ /*
4
+ * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
+ */
6
+
7
+ export interface InitReq extends RequestInit {
8
+ pathPrefix?: string
9
+ }
10
+
11
+ export function fetchReq<I, O>(path: string, init?: InitReq): Promise<O> {
12
+ const {pathPrefix, ...req} = init || {}
13
+
14
+ const url = pathPrefix ? `${pathPrefix}${path}` : path
15
+
16
+ return fetch(url, req).then(r => r.json().then((body: O) => {
17
+ if (!r.ok) { throw body; }
18
+ return body;
19
+ })) as Promise<O>
20
+ }
21
+
22
+ // NotifyStreamEntityArrival is a callback that will be called on streaming entity arrival
23
+ export type NotifyStreamEntityArrival<T> = (resp: T) => void
24
+
25
+ /**
26
+ * fetchStreamingRequest is able to handle grpc-gateway server side streaming call
27
+ * it takes NotifyStreamEntityArrival that lets users respond to entity arrival during the call
28
+ * all entities will be returned as an array after the call finishes.
29
+ **/
30
+ export async function fetchStreamingRequest<S, R>(path: string, callback?: NotifyStreamEntityArrival<R>, init?: InitReq) {
31
+ const {pathPrefix, ...req} = init || {}
32
+ const url = pathPrefix ?`${pathPrefix}${path}` : path
33
+ const result = await fetch(url, req)
34
+ // needs to use the .ok to check the status of HTTP status code
35
+ // http other than 200 will not throw an error, instead the .ok will become false.
36
+ // see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#
37
+ if (!result.ok) {
38
+ const resp = await result.json()
39
+ const errMsg = resp.error && resp.error.message ? resp.error.message : ""
40
+ throw new Error(errMsg)
41
+ }
42
+
43
+ if (!result.body) {
44
+ throw new Error("response doesnt have a body")
45
+ }
46
+
47
+ await result.body
48
+ .pipeThrough(new TextDecoderStream())
49
+ .pipeThrough<R>(getNewLineDelimitedJSONDecodingStream<R>())
50
+ .pipeTo(getNotifyEntityArrivalSink((e: R) => {
51
+ if (callback) {
52
+ callback(e)
53
+ }
54
+ }))
55
+
56
+ // wait for the streaming to finish and return the success respond
57
+ return
58
+ }
59
+
60
+ /**
61
+ * JSONStringStreamController represents the transform controller that's able to transform the incoming
62
+ * new line delimited json content stream into entities and able to push the entity to the down stream
63
+ */
64
+ interface JSONStringStreamController<T> extends TransformStreamDefaultController {
65
+ buf?: string
66
+ pos?: number
67
+ enqueue: (s: T) => void
68
+ }
69
+
70
+ /**
71
+ * getNewLineDelimitedJSONDecodingStream returns a TransformStream that's able to handle new line delimited json stream content into parsed entities
72
+ */
73
+ function getNewLineDelimitedJSONDecodingStream<T>(): TransformStream<string, T> {
74
+ return new TransformStream({
75
+ start(controller: JSONStringStreamController<T>) {
76
+ controller.buf = ''
77
+ controller.pos = 0
78
+ },
79
+
80
+ transform(chunk: string, controller: JSONStringStreamController<T>) {
81
+ if (controller.buf === undefined) {
82
+ controller.buf = ''
83
+ }
84
+ if (controller.pos === undefined) {
85
+ controller.pos = 0
86
+ }
87
+ controller.buf += chunk
88
+ while (controller.pos < controller.buf.length) {
89
+ if (controller.buf[controller.pos] === '\n') {
90
+ const line = controller.buf.substring(0, controller.pos)
91
+ const response = JSON.parse(line)
92
+ controller.enqueue(response.result)
93
+ controller.buf = controller.buf.substring(controller.pos + 1)
94
+ controller.pos = 0
95
+ } else {
96
+ ++controller.pos
97
+ }
98
+ }
99
+ }
100
+ })
101
+
102
+ }
103
+
104
+ /**
105
+ * getNotifyEntityArrivalSink takes the NotifyStreamEntityArrival callback and return
106
+ * a sink that will call the callback on entity arrival
107
+ * @param notifyCallback
108
+ */
109
+ function getNotifyEntityArrivalSink<T>(notifyCallback: NotifyStreamEntityArrival<T>) {
110
+ return new WritableStream<T>({
111
+ write(entity: T) {
112
+ notifyCallback(entity)
113
+ }
114
+ })
115
+ }
116
+
117
+ type Primitive = string | boolean | number;
118
+ type RequestPayload = Record<string, unknown>;
119
+ type FlattenedRequestPayload = Record<string, Primitive | Array<Primitive>>;
120
+
121
+ /**
122
+ * Checks if given value is a plain object
123
+ * Logic copied and adapted from below source:
124
+ * https://github.com/char0n/ramda-adjunct/blob/master/src/isPlainObj.js
125
+ * @param {unknown} value
126
+ * @return {boolean}
127
+ */
128
+ function isPlainObject(value: unknown): boolean {
129
+ const isObject =
130
+ Object.prototype.toString.call(value).slice(8, -1) === "Object";
131
+ const isObjLike = value !== null && isObject;
132
+
133
+ if (!isObjLike || !isObject) {
134
+ return false;
135
+ }
136
+
137
+ const proto = Object.getPrototypeOf(value);
138
+
139
+ const hasObjectConstructor =
140
+ typeof proto === "object" &&
141
+ proto.constructor === Object.prototype.constructor;
142
+
143
+ return hasObjectConstructor;
144
+ }
145
+
146
+ /**
147
+ * Checks if given value is of a primitive type
148
+ * @param {unknown} value
149
+ * @return {boolean}
150
+ */
151
+ function isPrimitive(value: unknown): boolean {
152
+ return ["string", "number", "boolean"].some(t => typeof value === t);
153
+ }
154
+
155
+ /**
156
+ * Checks if given primitive is zero-value
157
+ * @param {Primitive} value
158
+ * @return {boolean}
159
+ */
160
+ function isZeroValuePrimitive(value: Primitive): boolean {
161
+ return value === false || value === 0 || value === "";
162
+ }
163
+
164
+ /**
165
+ * Flattens a deeply nested request payload and returns an object
166
+ * with only primitive values and non-empty array of primitive values
167
+ * as per https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
168
+ * @param {RequestPayload} requestPayload
169
+ * @param {String} path
170
+ * @return {FlattenedRequestPayload>}
171
+ */
172
+ function flattenRequestPayload<T extends RequestPayload>(
173
+ requestPayload: T,
174
+ path: string = ""
175
+ ): FlattenedRequestPayload {
176
+ return Object.keys(requestPayload).reduce(
177
+ (acc: T, key: string): T => {
178
+ const value = requestPayload[key];
179
+ const newPath = path ? [path, key].join(".") : key;
180
+
181
+ const isNonEmptyPrimitiveArray =
182
+ Array.isArray(value) &&
183
+ value.every(v => isPrimitive(v)) &&
184
+ value.length > 0;
185
+
186
+ const isNonZeroValuePrimitive =
187
+ isPrimitive(value) && !isZeroValuePrimitive(value as Primitive);
188
+
189
+ let objectToMerge = {};
190
+
191
+ if (isPlainObject(value)) {
192
+ objectToMerge = flattenRequestPayload(value as RequestPayload, newPath);
193
+ } else if (isNonZeroValuePrimitive || isNonEmptyPrimitiveArray) {
194
+ objectToMerge = { [newPath]: value };
195
+ }
196
+
197
+ return { ...acc, ...objectToMerge };
198
+ },
199
+ {} as T
200
+ ) as FlattenedRequestPayload;
201
+ }
202
+
203
+ /**
204
+ * Renders a deeply nested request payload into a string of URL search
205
+ * parameters by first flattening the request payload and then removing keys
206
+ * which are already present in the URL path.
207
+ * @param {RequestPayload} requestPayload
208
+ * @param {string[]} urlPathParams
209
+ * @return {string}
210
+ */
211
+ export function renderURLSearchParams<T extends RequestPayload>(
212
+ requestPayload: T,
213
+ urlPathParams: string[] = []
214
+ ): string {
215
+ const flattenedRequestPayload = flattenRequestPayload(requestPayload);
216
+
217
+ const urlSearchParams = Object.keys(flattenedRequestPayload).reduce(
218
+ (acc: string[][], key: string): string[][] => {
219
+ // key should not be present in the url path as a parameter
220
+ const value = flattenedRequestPayload[key];
221
+ if (urlPathParams.find(f => f === key)) {
222
+ return acc;
223
+ }
224
+ return Array.isArray(value)
225
+ ? [...acc, ...value.map(m => [key, m.toString()])]
226
+ : (acc = [...acc, [key, value.toString()]]);
227
+ },
228
+ [] as string[][]
229
+ );
230
+
231
+ return new URLSearchParams(urlSearchParams).toString();
232
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name":"@daocloud-proto/mcamel-rabbitmq",
3
- "version":"0.4.0-11",
3
+ "version":"0.4.0-113",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/rabbitmq.pb.ts CHANGED
@@ -4,7 +4,28 @@
4
4
  * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
5
  */
6
6
 
7
- import * as fm from "../../v1alpha1/ts_out/api"
7
+ import * as CommonCommon from "./common.pb"
8
+ import * as fm from "./fetch.pb"
9
+
10
+ type Absent<T, K extends keyof T> = { [k in Exclude<keyof T, K>]?: undefined };
11
+ type OneOf<T> =
12
+ | { [k in keyof T]?: undefined }
13
+ | (
14
+ keyof T extends infer K ?
15
+ (K extends string & keyof T ? { [k in K]: T[K] } & Absent<T, K>
16
+ : never)
17
+ : never);
18
+
19
+ export enum Status {
20
+ Failed = "Failed",
21
+ Running = "Running",
22
+ Creating = "Creating",
23
+ }
24
+
25
+ export enum GetRabbitMqListReqSortDir {
26
+ ASC = "ASC",
27
+ DESC = "DESC",
28
+ }
8
29
 
9
30
  export enum CreateRabbitMqReqServiceType {
10
31
  ClusterIP = "ClusterIP",
@@ -19,7 +40,9 @@ export enum GetRabbitMqParamRespSelectSelectType {
19
40
 
20
41
  export type GetRabbitMqListReq = {
21
42
  page?: number
22
- size?: number
43
+ pageSize?: number
44
+ sortDir?: GetRabbitMqListReqSortDir
45
+ sortBy?: string
23
46
  searchKey?: string
24
47
  }
25
48
 
@@ -42,7 +65,6 @@ export type CreateRabbitMqReq = {
42
65
  describe?: string
43
66
  version?: string
44
67
  replicas?: number
45
- resource?: string
46
68
  storageClassName?: string
47
69
  storageCapacity?: string
48
70
  defaultUser?: string
@@ -50,6 +72,10 @@ export type CreateRabbitMqReq = {
50
72
  serviceType?: CreateRabbitMqReqServiceType
51
73
  serviceAnnotations?: {[key: string]: string}
52
74
  ports?: CreateRabbitMqReqPorts[]
75
+ cpuRequest?: string
76
+ cpuLimit?: string
77
+ memoryRequest?: string
78
+ memoryLimit?: string
53
79
  }
54
80
 
55
81
  export type UpdateRabbitMqReq = {
@@ -58,24 +84,41 @@ export type UpdateRabbitMqReq = {
58
84
  name?: string
59
85
  defaultUser?: string
60
86
  defaultPass?: string
61
- resource?: string
62
87
  replicas?: number
63
88
  storageCapacity?: string
64
89
  serviceType?: CreateRabbitMqReqServiceType
65
90
  serviceAnnotations?: {[key: string]: string}
66
91
  describe?: string
67
92
  ports?: CreateRabbitMqReqPorts[]
93
+ cpuRequest?: string
94
+ cpuLimit?: string
95
+ memoryRequest?: string
96
+ memoryLimit?: string
68
97
  }
69
98
 
70
99
  export type UpdateRabbitMqResp = {
71
100
  message?: string
72
101
  }
73
102
 
74
- export type GetRabbitMqParamRespSelectData = {
75
- data?: {[key: string]: string}
103
+ export type GetRabbitMqParamRespSelectDataStringValue = {
76
104
  value?: string
77
105
  }
78
106
 
107
+ export type GetRabbitMqParamRespSelectDataResourceValue = {
108
+ cpuRequest?: number
109
+ cpuLimit?: number
110
+ memoryRequest?: number
111
+ memoryLimit?: number
112
+ }
113
+
114
+
115
+ type BaseGetRabbitMqParamRespSelectData = {
116
+ data?: {[key: string]: string}
117
+ }
118
+
119
+ export type GetRabbitMqParamRespSelectData = BaseGetRabbitMqParamRespSelectData
120
+ & OneOf<{ sValue: GetRabbitMqParamRespSelectDataStringValue; rValue: GetRabbitMqParamRespSelectDataResourceValue }>
121
+
79
122
  export type GetRabbitMqParamRespSelect = {
80
123
  selectType?: GetRabbitMqParamRespSelectSelectType
81
124
  data?: GetRabbitMqParamRespSelectData[]
@@ -103,7 +146,8 @@ export type GetRabbitMqOperatorVersionListRespGetRabbitMqOperatorVersionListData
103
146
  }
104
147
 
105
148
  export type GetRabbitMqOperatorVersionListResp = {
106
- data?: GetRabbitMqOperatorVersionListRespGetRabbitMqOperatorVersionListData[]
149
+ items?: GetRabbitMqOperatorVersionListRespGetRabbitMqOperatorVersionListData[]
150
+ pagination?: CommonCommon.Pagination
107
151
  }
108
152
 
109
153
  export type DeleteRabbitMqReq = {
@@ -132,7 +176,7 @@ export type GetRabbitMqNodeListReq = {
132
176
 
133
177
  export type GetRabbitMqNodeListRespData = {
134
178
  podName?: string
135
- status?: string
179
+ status?: Status
136
180
  nodeName?: string
137
181
  ip?: string
138
182
  restart?: number
@@ -142,7 +186,15 @@ export type GetRabbitMqNodeListRespData = {
142
186
  }
143
187
 
144
188
  export type GetRabbitMqNodeListResp = {
145
- data?: GetRabbitMqNodeListRespData[]
189
+ items?: GetRabbitMqNodeListRespData[]
190
+ pagination?: CommonCommon.Pagination
191
+ }
192
+
193
+ export type GetRabbitMqGrafanaAddrReq = {
194
+ }
195
+
196
+ export type GetRabbitMqGrafanaAddrResp = {
197
+ data?: string
146
198
  }
147
199
 
148
200
  export type GetRabbitMqReq = {
@@ -156,137 +208,30 @@ export type GetRabbitMqResp = {
156
208
  }
157
209
 
158
210
  export type GetRabbitMqListResp = {
159
- data?: RabbitmqClusterList
211
+ items?: RabbitmqClusterItem[]
212
+ pagination?: CommonCommon.Pagination
160
213
  }
161
214
 
162
215
  export type RabbitmqClusterItemExtend = {
163
- atLeastOneEndpointAvailable?: boolean
216
+ status?: Status
164
217
  podsAreReadyNum?: number
165
218
  webManagerAddr?: string
166
219
  clusterIPs?: string[]
167
220
  }
168
221
 
169
- export type RabbitmqClusterListMetadata = {
170
- remainingItemCount?: number
171
- }
172
-
173
- export type RabbitmqClusterList = {
174
- metadata?: RabbitmqClusterListMetadata
175
- items?: RabbitmqClusterItem[]
176
- }
177
-
178
222
  export type RabbitmqClusterItemMetadata = {
179
223
  annotations?: {[key: string]: string}
180
- creationTimestamp?: string
181
- finalizers?: string[]
182
- generation?: number
224
+ creationTimestamp?: number
183
225
  name?: string
184
226
  namespace?: string
185
- resourceVersion?: string
186
- uid?: string
187
- }
188
-
189
- export type RabbitmqClusterItemSpecOverride = {
190
- }
191
-
192
- export type RabbitmqClusterItemSpecPersistence = {
193
- storage?: string
194
- storageClassName?: string
195
- }
196
-
197
- export type RabbitmqClusterItemSpecRabbitmq = {
198
- additionalConfig?: string
199
- additionalPlugins?: string[]
200
- }
201
-
202
- export type RabbitmqClusterItemSpecResourcesLimits = {
203
- cpu?: string
204
- memory?: string
205
- }
206
-
207
- export type RabbitmqClusterItemSpecResourcesRequests = {
208
- cpu?: string
209
- memory?: string
210
- }
211
-
212
- export type RabbitmqClusterItemSpecResources = {
213
- limits?: RabbitmqClusterItemSpecResourcesLimits
214
- requests?: RabbitmqClusterItemSpecResourcesRequests
215
- }
216
-
217
- export type RabbitmqClusterItemSpecSecretBackend = {
218
- }
219
-
220
- export type RabbitmqClusterItemSpecServiceAnnotations = {
221
- asd?: string
222
- }
223
-
224
- export type RabbitmqClusterItemSpecService = {
225
- annotations?: RabbitmqClusterItemSpecServiceAnnotations
226
- type?: string
227
- }
228
-
229
- export type RabbitmqClusterItemSpecTls = {
230
- }
231
-
232
- export type RabbitmqClusterItemSpec = {
233
- image?: string
234
- override?: RabbitmqClusterItemSpecOverride
235
- persistence?: RabbitmqClusterItemSpecPersistence
236
- rabbitmq?: RabbitmqClusterItemSpecRabbitmq
237
- replicas?: number
238
- resources?: RabbitmqClusterItemSpecResources
239
- secretBackend?: RabbitmqClusterItemSpecSecretBackend
240
- service?: RabbitmqClusterItemSpecService
241
- terminationGracePeriodSeconds?: number
242
- tls?: RabbitmqClusterItemSpecTls
243
- }
244
-
245
- export type RabbitmqClusterItemStatusBinding = {
246
- name?: string
247
- }
248
-
249
- export type RabbitmqClusterItemStatusConditions = {
250
- lastTransitionTime?: string
251
- reason?: string
252
- status?: string
253
- type?: string
254
- }
255
-
256
- export type RabbitmqClusterItemStatusDefaultUserSecretReferenceKeys = {
257
- password?: string
258
- username?: string
259
- }
260
-
261
- export type RabbitmqClusterItemStatusDefaultUserSecretReference = {
262
- keys?: RabbitmqClusterItemStatusDefaultUserSecretReferenceKeys
263
- name?: string
264
- namespace?: string
265
- }
266
-
267
- export type RabbitmqClusterItemStatusDefaultUserServiceReference = {
268
- name?: string
269
- namespace?: string
270
- }
271
-
272
- export type RabbitmqClusterItemStatusDefaultUser = {
273
- secretReference?: RabbitmqClusterItemStatusDefaultUserSecretReference
274
- serviceReference?: RabbitmqClusterItemStatusDefaultUserServiceReference
275
- }
276
-
277
- export type RabbitmqClusterItemStatus = {
278
- binding?: RabbitmqClusterItemStatusBinding
279
- conditions?: RabbitmqClusterItemStatusConditions[]
280
- defaultUser?: RabbitmqClusterItemStatusDefaultUser
281
- observedGeneration?: number
282
227
  }
283
228
 
284
229
  export type RabbitmqClusterItem = {
285
230
  apiVersion?: string
286
231
  kind?: string
287
232
  metadata?: RabbitmqClusterItemMetadata
288
- spec?: RabbitmqClusterItemSpec
289
- status?: RabbitmqClusterItemStatus
233
+ spec?: CreateRabbitMqReq
234
+ status?: Status
290
235
  extend?: RabbitmqClusterItemExtend
291
236
  }
292
237
 
@@ -306,6 +251,9 @@ export class RabbitMq {
306
251
  static GetRabbitMqNodeList(req: GetRabbitMqNodeListReq, initReq?: fm.InitReq): Promise<GetRabbitMqNodeListResp> {
307
252
  return fm.fetchReq<GetRabbitMqNodeListReq, GetRabbitMqNodeListResp>(`/apis/mcamel.io/v1alpha1/rabbitmq/nodes/${req["cluster"]}/${req["namespace"]}/${req["name"]}?${fm.renderURLSearchParams(req, ["cluster", "namespace", "name"])}`, {...initReq, method: "GET"})
308
253
  }
254
+ static GetRabbitMqGrafanaAddr(req: GetRabbitMqGrafanaAddrReq, initReq?: fm.InitReq): Promise<GetRabbitMqGrafanaAddrResp> {
255
+ return fm.fetchReq<GetRabbitMqGrafanaAddrReq, GetRabbitMqGrafanaAddrResp>(`/apis/mcamel.io/v1alpha1/rabbitmq/grafana?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
256
+ }
309
257
  static CreateRabbitMq(req: CreateRabbitMqReq, initReq?: fm.InitReq): Promise<CreateRabbitMqResp> {
310
258
  return fm.fetchReq<CreateRabbitMqReq, CreateRabbitMqResp>(`/apis/mcamel.io/v1alpha1/rabbitmq`, {...initReq, method: "POST", body: JSON.stringify(req)})
311
259
  }
package/version.pb.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
5
5
  */
6
6
 
7
- import * as fm from "../../v1alpha1/ts_out/api"
7
+ import * as fm from "./fetch.pb"
8
8
  export type CommonReply = {
9
9
  code?: number
10
10
  msg?: string