@daocloud-proto/mcamel-rabbitmq 0.4.0-9 → 0.4.0-92

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 fm from "../../v1alpha1/ts_out/fetch.pb"
8
+ import * as CommonCommon from "./common.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-9",
3
+ "version":"0.4.0-92",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/rabbitmq.pb.ts CHANGED
@@ -4,7 +4,34 @@
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 "../../v1alpha1/ts_out/fetch.pb"
8
+ import * as CommonCommon from "./common.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
+ }
29
+
30
+ export enum CreateRabbitMqReqServiceType {
31
+ ClusterIP = "ClusterIP",
32
+ NodePort = "NodePort",
33
+ LoadBalancer = "LoadBalancer",
34
+ }
8
35
 
9
36
  export enum GetRabbitMqParamRespSelectSelectType {
10
37
  Single = "Single",
@@ -13,7 +40,9 @@ export enum GetRabbitMqParamRespSelectSelectType {
13
40
 
14
41
  export type GetRabbitMqListReq = {
15
42
  page?: number
16
- size?: number
43
+ pageSize?: number
44
+ sortDir?: GetRabbitMqListReqSortDir
45
+ sortBy?: string
17
46
  searchKey?: string
18
47
  }
19
48
 
@@ -36,14 +65,17 @@ export type CreateRabbitMqReq = {
36
65
  describe?: string
37
66
  version?: string
38
67
  replicas?: number
39
- resource?: string
40
68
  storageClassName?: string
41
69
  storageCapacity?: string
42
70
  defaultUser?: string
43
71
  defaultPass?: string
44
- serviceType?: string
72
+ serviceType?: CreateRabbitMqReqServiceType
45
73
  serviceAnnotations?: {[key: string]: string}
46
74
  ports?: CreateRabbitMqReqPorts[]
75
+ cpuRequest?: string
76
+ cpuLimit?: string
77
+ memoryRequest?: string
78
+ memoryLimit?: string
47
79
  }
48
80
 
49
81
  export type UpdateRabbitMqReq = {
@@ -52,31 +84,48 @@ export type UpdateRabbitMqReq = {
52
84
  name?: string
53
85
  defaultUser?: string
54
86
  defaultPass?: string
55
- resource?: string
56
87
  replicas?: number
57
88
  storageCapacity?: string
58
- serviceType?: string
89
+ serviceType?: CreateRabbitMqReqServiceType
59
90
  serviceAnnotations?: {[key: string]: string}
60
91
  describe?: string
61
92
  ports?: CreateRabbitMqReqPorts[]
93
+ cpuRequest?: string
94
+ cpuLimit?: string
95
+ memoryRequest?: string
96
+ memoryLimit?: string
62
97
  }
63
98
 
64
99
  export type UpdateRabbitMqResp = {
65
100
  message?: string
66
101
  }
67
102
 
68
- export type GetRabbitMqParamRespSelectData = {
103
+ export type GetRabbitMqParamRespSelectDataStringValue = {
104
+ value?: string
105
+ }
106
+
107
+ export type GetRabbitMqParamRespSelectDataResourceValue = {
108
+ cpuRequest?: number
109
+ cpuLimit?: number
110
+ memoryRequest?: number
111
+ memoryLimit?: number
112
+ }
113
+
114
+
115
+ type BaseGetRabbitMqParamRespSelectData = {
69
116
  data?: {[key: string]: string}
70
117
  }
71
118
 
119
+ export type GetRabbitMqParamRespSelectData = BaseGetRabbitMqParamRespSelectData
120
+ & OneOf<{ sValue: GetRabbitMqParamRespSelectDataStringValue; rValue: GetRabbitMqParamRespSelectDataResourceValue }>
121
+
72
122
  export type GetRabbitMqParamRespSelect = {
73
123
  selectType?: GetRabbitMqParamRespSelectSelectType
74
124
  data?: GetRabbitMqParamRespSelectData[]
75
- value?: string[]
76
125
  }
77
126
 
78
127
  export type GetRabbitMqParamResp = {
79
- version?: string
128
+ version?: GetRabbitMqParamRespSelect
80
129
  replicas?: GetRabbitMqParamRespSelect
81
130
  resource?: GetRabbitMqParamRespSelect
82
131
  storage?: GetRabbitMqParamRespSelect
@@ -97,7 +146,8 @@ export type GetRabbitMqOperatorVersionListRespGetRabbitMqOperatorVersionListData
97
146
  }
98
147
 
99
148
  export type GetRabbitMqOperatorVersionListResp = {
100
- data?: GetRabbitMqOperatorVersionListRespGetRabbitMqOperatorVersionListData[]
149
+ items?: GetRabbitMqOperatorVersionListRespGetRabbitMqOperatorVersionListData[]
150
+ pagination?: CommonCommon.Pagination
101
151
  }
102
152
 
103
153
  export type DeleteRabbitMqReq = {
@@ -126,7 +176,7 @@ export type GetRabbitMqNodeListReq = {
126
176
 
127
177
  export type GetRabbitMqNodeListRespData = {
128
178
  podName?: string
129
- status?: string
179
+ status?: Status
130
180
  nodeName?: string
131
181
  ip?: string
132
182
  restart?: number
@@ -136,7 +186,15 @@ export type GetRabbitMqNodeListRespData = {
136
186
  }
137
187
 
138
188
  export type GetRabbitMqNodeListResp = {
139
- data?: GetRabbitMqNodeListRespData[]
189
+ items?: GetRabbitMqNodeListRespData[]
190
+ pagination?: CommonCommon.Pagination
191
+ }
192
+
193
+ export type GetRabbitMqGrafanaAddrReq = {
194
+ }
195
+
196
+ export type GetRabbitMqGrafanaAddrResp = {
197
+ data?: string
140
198
  }
141
199
 
142
200
  export type GetRabbitMqReq = {
@@ -150,25 +208,17 @@ export type GetRabbitMqResp = {
150
208
  }
151
209
 
152
210
  export type GetRabbitMqListResp = {
153
- data?: RabbitmqClusterList
211
+ items?: RabbitmqClusterItem[]
212
+ pagination?: CommonCommon.Pagination
154
213
  }
155
214
 
156
215
  export type RabbitmqClusterItemExtend = {
157
- atLeastOneEndpointAvailable?: boolean
216
+ status?: Status
158
217
  podsAreReadyNum?: number
159
218
  webManagerAddr?: string
160
219
  clusterIPs?: string[]
161
220
  }
162
221
 
163
- export type RabbitmqClusterListMetadata = {
164
- remainingItemCount?: number
165
- }
166
-
167
- export type RabbitmqClusterList = {
168
- metadata?: RabbitmqClusterListMetadata
169
- items?: RabbitmqClusterItem[]
170
- }
171
-
172
222
  export type RabbitmqClusterItemMetadata = {
173
223
  annotations?: {[key: string]: string}
174
224
  creationTimestamp?: string
@@ -300,11 +350,14 @@ export class RabbitMq {
300
350
  static GetRabbitMqNodeList(req: GetRabbitMqNodeListReq, initReq?: fm.InitReq): Promise<GetRabbitMqNodeListResp> {
301
351
  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"})
302
352
  }
353
+ static GetRabbitMqGrafanaAddr(req: GetRabbitMqGrafanaAddrReq, initReq?: fm.InitReq): Promise<GetRabbitMqGrafanaAddrResp> {
354
+ return fm.fetchReq<GetRabbitMqGrafanaAddrReq, GetRabbitMqGrafanaAddrResp>(`/apis/mcamel.io/v1alpha1/rabbitmq/grafana?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
355
+ }
303
356
  static CreateRabbitMq(req: CreateRabbitMqReq, initReq?: fm.InitReq): Promise<CreateRabbitMqResp> {
304
357
  return fm.fetchReq<CreateRabbitMqReq, CreateRabbitMqResp>(`/apis/mcamel.io/v1alpha1/rabbitmq`, {...initReq, method: "POST", body: JSON.stringify(req)})
305
358
  }
306
359
  static UpdateRabbitMq(req: UpdateRabbitMqReq, initReq?: fm.InitReq): Promise<UpdateRabbitMqResp> {
307
- return fm.fetchReq<UpdateRabbitMqReq, UpdateRabbitMqResp>(`/apis/mcamel.io/v1alpha1/rabbitmq/${req["cluster"]}/${req["namespace"]}/${req["name"]}`, {...initReq, method: "PUT", body: JSON.stringify(req)})
360
+ return fm.fetchReq<UpdateRabbitMqReq, UpdateRabbitMqResp>(`/apis/mcamel.io/v1alpha1/rabbitmq/${req["cluster"]}/${req["namespace"]}/${req["name"]}`, {...initReq, method: "PATCH", body: JSON.stringify(req)})
308
361
  }
309
362
  static DeleteRabbitMq(req: DeleteRabbitMqReq, initReq?: fm.InitReq): Promise<DeleteRabbitMqResp> {
310
363
  return fm.fetchReq<DeleteRabbitMqReq, DeleteRabbitMqResp>(`/apis/mcamel.io/v1alpha1/rabbitmq/${req["cluster"]}/${req["namespace"]}/${req["name"]}`, {...initReq, method: "DELETE"})
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 "../../v1alpha1/ts_out/fetch.pb"
8
8
  export type CommonReply = {
9
9
  code?: number
10
10
  msg?: string