@zilliz/milvus2-sdk-node 2.2.9 → 2.2.11
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/README.md +76 -12
- package/dist/milvus/MilvusClient.d.ts +21 -2
- package/dist/milvus/MilvusClient.js +35 -29
- package/dist/milvus/MilvusClient.js.map +1 -1
- package/dist/milvus/OrmClient.d.ts +19 -0
- package/dist/milvus/OrmClient.js +77 -0
- package/dist/milvus/OrmClient.js.map +1 -0
- package/dist/milvus/const/ErrorReason.d.ts +36 -31
- package/dist/milvus/const/ErrorReason.js +39 -32
- package/dist/milvus/const/ErrorReason.js.map +1 -1
- package/dist/milvus/const/Milvus.d.ts +2 -9
- package/dist/milvus/const/Milvus.js +16 -33
- package/dist/milvus/const/Milvus.js.map +1 -1
- package/dist/milvus/const/client.d.ts +5 -0
- package/dist/milvus/const/client.js +10 -0
- package/dist/milvus/const/client.js.map +1 -0
- package/dist/milvus/const/defaults.d.ts +11 -0
- package/dist/milvus/const/defaults.js +16 -0
- package/dist/milvus/const/defaults.js.map +1 -0
- package/dist/milvus/const/highLevel.d.ts +23 -0
- package/dist/milvus/const/highLevel.js +26 -0
- package/dist/milvus/const/highLevel.js.map +1 -0
- package/dist/milvus/const/index.d.ts +5 -0
- package/dist/milvus/{types.js → const/index.js} +7 -10
- package/dist/milvus/const/index.js.map +1 -0
- package/dist/milvus/const/limits.d.ts +2 -0
- package/dist/milvus/const/limits.js +7 -0
- package/dist/milvus/const/limits.js.map +1 -0
- package/dist/milvus/{BaseClient.d.ts → grpc/BaseClient.d.ts} +20 -8
- package/dist/milvus/grpc/BaseClient.js +83 -0
- package/dist/milvus/grpc/BaseClient.js.map +1 -0
- package/dist/milvus/{Collection.d.ts → grpc/Collection.d.ts} +32 -3
- package/dist/milvus/grpc/Collection.js +786 -0
- package/dist/milvus/grpc/Collection.js.map +1 -0
- package/dist/milvus/{Data.d.ts → grpc/Data.d.ts} +68 -10
- package/dist/milvus/grpc/Data.js +880 -0
- package/dist/milvus/grpc/Data.js.map +1 -0
- package/dist/milvus/grpc/Database.d.ts +69 -0
- package/dist/milvus/grpc/Database.js +98 -0
- package/dist/milvus/grpc/Database.js.map +1 -0
- package/dist/milvus/grpc/GrpcClient.d.ts +46 -0
- package/dist/milvus/grpc/GrpcClient.js +150 -0
- package/dist/milvus/grpc/GrpcClient.js.map +1 -0
- package/dist/milvus/{MilvusIndex.d.ts → grpc/MilvusIndex.d.ts} +1 -1
- package/dist/milvus/grpc/MilvusIndex.js +203 -0
- package/dist/milvus/grpc/MilvusIndex.js.map +1 -0
- package/dist/milvus/{Partition.d.ts → grpc/Partition.d.ts} +1 -1
- package/dist/milvus/grpc/Partition.js +265 -0
- package/dist/milvus/grpc/Partition.js.map +1 -0
- package/dist/milvus/{Resource.d.ts → grpc/Resource.d.ts} +2 -2
- package/dist/milvus/grpc/Resource.js +250 -0
- package/dist/milvus/grpc/Resource.js.map +1 -0
- package/dist/milvus/{User.d.ts → grpc/User.d.ts} +1 -1
- package/dist/milvus/grpc/User.js +619 -0
- package/dist/milvus/grpc/User.js.map +1 -0
- package/dist/milvus/index.d.ts +4 -13
- package/dist/milvus/index.js +6 -14
- package/dist/milvus/index.js.map +1 -1
- package/dist/milvus/orm/Collection.d.ts +45 -0
- package/dist/milvus/orm/Collection.js +172 -0
- package/dist/milvus/orm/Collection.js.map +1 -0
- package/dist/milvus/orm/index.d.ts +2 -0
- package/dist/milvus/orm/index.js +19 -0
- package/dist/milvus/orm/index.js.map +1 -0
- package/dist/milvus/orm/utils.d.ts +27 -0
- package/dist/milvus/orm/utils.js +27 -0
- package/dist/milvus/orm/utils.js.map +1 -0
- package/dist/milvus/types/Client.d.ts +12 -1
- package/dist/milvus/types/Collection.d.ts +18 -4
- package/dist/milvus/types/Common.d.ts +1 -1
- package/dist/milvus/types/Data.d.ts +41 -5
- package/dist/milvus/types/Database.d.ts +12 -0
- package/dist/milvus/types/{Index.js → Database.js} +1 -1
- package/dist/milvus/types/Database.js.map +1 -0
- package/dist/milvus/types/HighLevel.d.ts +13 -0
- package/dist/milvus/types/HighLevel.js +3 -0
- package/dist/milvus/types/HighLevel.js.map +1 -0
- package/dist/milvus/types/{Index.d.ts → MilvusIndex.d.ts} +3 -2
- package/dist/milvus/types/MilvusIndex.js +3 -0
- package/dist/milvus/types/MilvusIndex.js.map +1 -0
- package/dist/milvus/types/Resource.d.ts +1 -1
- package/dist/milvus/types/User.d.ts +1 -1
- package/dist/milvus/types/index.d.ts +12 -0
- package/dist/milvus/types/index.js +30 -0
- package/dist/milvus/types/index.js.map +1 -0
- package/dist/{utils → milvus/utils}/Blob.js +4 -4
- package/dist/milvus/utils/Blob.js.map +1 -0
- package/dist/{utils → milvus/utils}/Format.d.ts +66 -2
- package/dist/milvus/utils/Format.js +416 -0
- package/dist/milvus/utils/Format.js.map +1 -0
- package/dist/{utils → milvus/utils}/Function.d.ts +1 -1
- package/dist/{utils → milvus/utils}/Function.js +7 -7
- package/dist/milvus/utils/Function.js.map +1 -0
- package/dist/{utils → milvus/utils}/Grpc.d.ts +9 -8
- package/dist/milvus/utils/Grpc.js +190 -0
- package/dist/milvus/utils/Grpc.js.map +1 -0
- package/dist/{utils → milvus/utils}/Validate.d.ts +7 -1
- package/dist/milvus/utils/Validate.js +140 -0
- package/dist/milvus/utils/Validate.js.map +1 -0
- package/dist/{utils → milvus/utils}/index.d.ts +2 -0
- package/dist/{utils → milvus/utils}/index.js +2 -0
- package/dist/milvus/utils/index.js.map +1 -0
- package/dist/milvus/utils/logger.d.ts +1 -0
- package/dist/milvus/utils/logger.js +18 -0
- package/dist/milvus/utils/logger.js.map +1 -0
- package/dist/proto/proto/common.proto +38 -14
- package/dist/proto/proto/google/protobuf/descriptor.proto +8 -4
- package/dist/proto/proto/milvus.proto +86 -83
- package/dist/proto/proto/schema.proto +5 -0
- package/dist/sdk.json +1 -1
- package/package.json +14 -11
- package/dist/milvus/BaseClient.js +0 -62
- package/dist/milvus/BaseClient.js.map +0 -1
- package/dist/milvus/Collection.js +0 -960
- package/dist/milvus/Collection.js.map +0 -1
- package/dist/milvus/Data.js +0 -909
- package/dist/milvus/Data.js.map +0 -1
- package/dist/milvus/GrpcClient.d.ts +0 -32
- package/dist/milvus/GrpcClient.js +0 -236
- package/dist/milvus/GrpcClient.js.map +0 -1
- package/dist/milvus/MilvusIndex.js +0 -299
- package/dist/milvus/MilvusIndex.js.map +0 -1
- package/dist/milvus/Partition.js +0 -369
- package/dist/milvus/Partition.js.map +0 -1
- package/dist/milvus/Resource.js +0 -356
- package/dist/milvus/Resource.js.map +0 -1
- package/dist/milvus/User.js +0 -806
- package/dist/milvus/User.js.map +0 -1
- package/dist/milvus/Utils.d.ts +0 -1
- package/dist/milvus/Utils.js +0 -8
- package/dist/milvus/Utils.js.map +0 -1
- package/dist/milvus/types/Index.js.map +0 -1
- package/dist/milvus/types.d.ts +0 -9
- package/dist/milvus/types.js.map +0 -1
- package/dist/proto/proto/feder.proto +0 -40
- package/dist/proto/proto/msg.proto +0 -107
- package/dist/utils/Blob.js.map +0 -1
- package/dist/utils/Format.js +0 -252
- package/dist/utils/Format.js.map +0 -1
- package/dist/utils/Function.js.map +0 -1
- package/dist/utils/Grpc.js +0 -170
- package/dist/utils/Grpc.js.map +0 -1
- package/dist/utils/Validate.js +0 -124
- package/dist/utils/Validate.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/test.d.ts +0 -15
- package/dist/utils/test.js +0 -98
- package/dist/utils/test.js.map +0 -1
- /package/dist/{utils → milvus/utils}/Blob.d.ts +0 -0
package/dist/milvus/User.js
DELETED
|
@@ -1,806 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.User = void 0;
|
|
55
|
-
var utils_1 = require("../utils");
|
|
56
|
-
var Resource_1 = require("./Resource");
|
|
57
|
-
var _1 = require(".");
|
|
58
|
-
var User = /** @class */ (function (_super) {
|
|
59
|
-
__extends(User, _super);
|
|
60
|
-
function User() {
|
|
61
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Create user in milvus
|
|
65
|
-
*
|
|
66
|
-
* @param data
|
|
67
|
-
* | Property | Type | Description |
|
|
68
|
-
* | :-- | :-- | :-- |
|
|
69
|
-
* | username | String | username |
|
|
70
|
-
* | password | String | user password |
|
|
71
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
72
|
-
*
|
|
73
|
-
* @returns
|
|
74
|
-
* | Property | Description |
|
|
75
|
-
* | :-- | :-- |
|
|
76
|
-
* | error_code | Error code number |
|
|
77
|
-
* | reason | Error cause|
|
|
78
|
-
*
|
|
79
|
-
* #### Example
|
|
80
|
-
*
|
|
81
|
-
* ```
|
|
82
|
-
* milvusClient.createUser({
|
|
83
|
-
* username: NAME,
|
|
84
|
-
* password: PASSWORD,
|
|
85
|
-
* });
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
User.prototype.createUser = function (data) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
var encryptedPassword, promise;
|
|
91
|
-
return __generator(this, function (_a) {
|
|
92
|
-
switch (_a.label) {
|
|
93
|
-
case 0:
|
|
94
|
-
if (data.username === undefined || data.password === undefined) {
|
|
95
|
-
throw new Error(_1.ERROR_REASONS.USERNAME_PWD_ARE_REQUIRED);
|
|
96
|
-
}
|
|
97
|
-
encryptedPassword = (0, utils_1.stringToBase64)(data.password);
|
|
98
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateCredential', {
|
|
99
|
-
username: data.username,
|
|
100
|
-
password: encryptedPassword,
|
|
101
|
-
}, data.timeout || this.timeout)];
|
|
102
|
-
case 1:
|
|
103
|
-
promise = _a.sent();
|
|
104
|
-
return [2 /*return*/, promise];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Update user in milvus
|
|
111
|
-
*
|
|
112
|
-
* @param data
|
|
113
|
-
* | Property | Type | Description |
|
|
114
|
-
* | :-- | :-- | :-- |
|
|
115
|
-
* | username | String | username |
|
|
116
|
-
* | password | String | user password |
|
|
117
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
118
|
-
*
|
|
119
|
-
* @returns
|
|
120
|
-
* | Property | Description |
|
|
121
|
-
* | :-- | :-- |
|
|
122
|
-
* | error_code | Error code number |
|
|
123
|
-
* | reason | Error cause|
|
|
124
|
-
*
|
|
125
|
-
* #### Example
|
|
126
|
-
*
|
|
127
|
-
* ```
|
|
128
|
-
* milvusClient.updateUser({
|
|
129
|
-
* username: NAME,
|
|
130
|
-
* newPassword: PASSWORD,
|
|
131
|
-
* oldPassword: PASSWORD,
|
|
132
|
-
* });
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
User.prototype.updateUser = function (data) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var encryptedOldPwd, encryptedNewPwd, promise;
|
|
138
|
-
return __generator(this, function (_a) {
|
|
139
|
-
switch (_a.label) {
|
|
140
|
-
case 0:
|
|
141
|
-
if (data.username === undefined ||
|
|
142
|
-
data.newPassword === undefined ||
|
|
143
|
-
data.oldPassword === undefined) {
|
|
144
|
-
throw new Error(_1.ERROR_REASONS.USERNAME_PWD_ARE_REQUIRED);
|
|
145
|
-
}
|
|
146
|
-
encryptedOldPwd = (0, utils_1.stringToBase64)(data.oldPassword);
|
|
147
|
-
encryptedNewPwd = (0, utils_1.stringToBase64)(data.newPassword);
|
|
148
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'UpdateCredential', {
|
|
149
|
-
username: data.username,
|
|
150
|
-
oldPassword: encryptedOldPwd,
|
|
151
|
-
newPassword: encryptedNewPwd,
|
|
152
|
-
}, data.timeout || this.timeout)];
|
|
153
|
-
case 1:
|
|
154
|
-
promise = _a.sent();
|
|
155
|
-
return [2 /*return*/, promise];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Delete user in milvus
|
|
162
|
-
*
|
|
163
|
-
* @param data
|
|
164
|
-
* | Property | Type | Description |
|
|
165
|
-
* | :-- | :-- | :-- |
|
|
166
|
-
* | username | String | username |
|
|
167
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
168
|
-
*
|
|
169
|
-
* @returns
|
|
170
|
-
* | Property | Description |
|
|
171
|
-
* | :-- | :-- |
|
|
172
|
-
* | error_code | Error code number |
|
|
173
|
-
* | reason | Error cause|
|
|
174
|
-
*
|
|
175
|
-
* #### Example
|
|
176
|
-
*
|
|
177
|
-
* ```
|
|
178
|
-
* milvusClient.deleteUser({
|
|
179
|
-
* username: NAME,
|
|
180
|
-
* });
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
User.prototype.deleteUser = function (data) {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
-
var promise;
|
|
186
|
-
return __generator(this, function (_a) {
|
|
187
|
-
switch (_a.label) {
|
|
188
|
-
case 0:
|
|
189
|
-
if (!data.username) {
|
|
190
|
-
throw new Error(_1.ERROR_REASONS.USERNAME_IS_REQUIRED);
|
|
191
|
-
}
|
|
192
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DeleteCredential', {
|
|
193
|
-
username: data.username,
|
|
194
|
-
}, data.timeout || this.timeout)];
|
|
195
|
-
case 1:
|
|
196
|
-
promise = _a.sent();
|
|
197
|
-
return [2 /*return*/, promise];
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
/**
|
|
203
|
-
* List user in milvus
|
|
204
|
-
*
|
|
205
|
-
* @param data
|
|
206
|
-
* | Property | Type | Description |
|
|
207
|
-
* | :-- | :-- | :-- |
|
|
208
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
209
|
-
*
|
|
210
|
-
* @returns
|
|
211
|
-
* | Property | Description |
|
|
212
|
-
* | :-- | :-- |
|
|
213
|
-
* | status | { error_code: number, reason: string } |
|
|
214
|
-
* | usernames | string[] |
|
|
215
|
-
*
|
|
216
|
-
* #### Example
|
|
217
|
-
*
|
|
218
|
-
* ```
|
|
219
|
-
* milvusClient.listUsers();
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
User.prototype.listUsers = function (data) {
|
|
223
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
-
var promise;
|
|
225
|
-
return __generator(this, function (_a) {
|
|
226
|
-
switch (_a.label) {
|
|
227
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ListCredUsers', {}, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout)];
|
|
228
|
-
case 1:
|
|
229
|
-
promise = _a.sent();
|
|
230
|
-
return [2 /*return*/, promise];
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Create user role
|
|
237
|
-
*
|
|
238
|
-
* @param data
|
|
239
|
-
* | Property | Type | Description |
|
|
240
|
-
* | :-- | :-- | :-- |
|
|
241
|
-
* | roleName | String | role name |
|
|
242
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
243
|
-
*
|
|
244
|
-
* @returns
|
|
245
|
-
* | Property | Description |
|
|
246
|
-
* | :-- | :-- |
|
|
247
|
-
* | status | { error_code: number, reason: string } |
|
|
248
|
-
* | reason | '' |
|
|
249
|
-
*
|
|
250
|
-
* #### Example
|
|
251
|
-
*
|
|
252
|
-
* ```
|
|
253
|
-
* milvusClient.createRole({roleName: 'myrole'});
|
|
254
|
-
* ```
|
|
255
|
-
*/
|
|
256
|
-
User.prototype.createRole = function (data) {
|
|
257
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
258
|
-
var promise;
|
|
259
|
-
return __generator(this, function (_a) {
|
|
260
|
-
switch (_a.label) {
|
|
261
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateRole', {
|
|
262
|
-
entity: { name: data.roleName },
|
|
263
|
-
}, data.timeout || this.timeout)];
|
|
264
|
-
case 1:
|
|
265
|
-
promise = _a.sent();
|
|
266
|
-
return [2 /*return*/, promise];
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* Drop user role
|
|
273
|
-
*
|
|
274
|
-
* @param data
|
|
275
|
-
* | Property | Type | Description |
|
|
276
|
-
* | :-- | :-- | :-- |
|
|
277
|
-
* | roleName | String | User name |
|
|
278
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
279
|
-
*
|
|
280
|
-
* @returns
|
|
281
|
-
* | Property | Description |
|
|
282
|
-
* | :-- | :-- |
|
|
283
|
-
* | status | { error_code: number, reason: string } |
|
|
284
|
-
* | reason | '' |
|
|
285
|
-
*
|
|
286
|
-
* #### Example
|
|
287
|
-
*
|
|
288
|
-
* ```
|
|
289
|
-
* milvusClient.dropRole({roleName: 'myrole'});
|
|
290
|
-
* ```
|
|
291
|
-
*/
|
|
292
|
-
User.prototype.dropRole = function (data) {
|
|
293
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
-
var promise;
|
|
295
|
-
return __generator(this, function (_a) {
|
|
296
|
-
switch (_a.label) {
|
|
297
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropRole', {
|
|
298
|
-
role_name: data.roleName,
|
|
299
|
-
}, data.timeout || this.timeout)];
|
|
300
|
-
case 1:
|
|
301
|
-
promise = _a.sent();
|
|
302
|
-
return [2 /*return*/, promise];
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
};
|
|
307
|
-
/**
|
|
308
|
-
* add user to role
|
|
309
|
-
*
|
|
310
|
-
* @param data
|
|
311
|
-
* | Property | Type | Description |
|
|
312
|
-
* | :-- | :-- | :-- |
|
|
313
|
-
* | username | String | User name |
|
|
314
|
-
* | roleName | String | Role name |
|
|
315
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
316
|
-
*
|
|
317
|
-
* @returns
|
|
318
|
-
* | Property | Description |
|
|
319
|
-
* | :-- | :-- |
|
|
320
|
-
* | status | { error_code: number, reason: string } |
|
|
321
|
-
* | reason | '' |
|
|
322
|
-
*
|
|
323
|
-
* #### Example
|
|
324
|
-
*
|
|
325
|
-
* ```
|
|
326
|
-
* milvusClient.addUserToRole({username: 'my', roleName: 'myrole'});
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
User.prototype.addUserToRole = function (data) {
|
|
330
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
331
|
-
var promise;
|
|
332
|
-
return __generator(this, function (_a) {
|
|
333
|
-
switch (_a.label) {
|
|
334
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'OperateUserRole', {
|
|
335
|
-
username: data.username,
|
|
336
|
-
role_name: data.roleName,
|
|
337
|
-
type: _1.OperateUserRoleType.AddUserToRole,
|
|
338
|
-
}, data.timeout || this.timeout)];
|
|
339
|
-
case 1:
|
|
340
|
-
promise = _a.sent();
|
|
341
|
-
return [2 /*return*/, promise];
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
};
|
|
346
|
-
/**
|
|
347
|
-
* remove user from role
|
|
348
|
-
*
|
|
349
|
-
* @param data
|
|
350
|
-
* | Property | Type | Description |
|
|
351
|
-
* | :-- | :-- | :-- |
|
|
352
|
-
* | username | String | User name |
|
|
353
|
-
* | roleName | String | Role name |
|
|
354
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
355
|
-
*
|
|
356
|
-
* @returns
|
|
357
|
-
* | Property | Description |
|
|
358
|
-
* | :-- | :-- |
|
|
359
|
-
* | status | { error_code: number, reason: string } |
|
|
360
|
-
* | reason | '' |
|
|
361
|
-
*
|
|
362
|
-
* #### Example
|
|
363
|
-
*
|
|
364
|
-
* ```
|
|
365
|
-
* milvusClient.removeUserFromRole({username: 'my', roleName: 'myrole'});
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
User.prototype.removeUserFromRole = function (data) {
|
|
369
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
370
|
-
var promise;
|
|
371
|
-
return __generator(this, function (_a) {
|
|
372
|
-
switch (_a.label) {
|
|
373
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'OperateUserRole', {
|
|
374
|
-
username: data.username,
|
|
375
|
-
role_name: data.roleName,
|
|
376
|
-
type: _1.OperateUserRoleType.RemoveUserFromRole,
|
|
377
|
-
}, data.timeout || this.timeout)];
|
|
378
|
-
case 1:
|
|
379
|
-
promise = _a.sent();
|
|
380
|
-
return [2 /*return*/, promise];
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
};
|
|
385
|
-
/**
|
|
386
|
-
* gets all users that belong to a specified role
|
|
387
|
-
*
|
|
388
|
-
* @param data
|
|
389
|
-
* | Property | Type | Description |
|
|
390
|
-
* | :-- | :-- | :-- |
|
|
391
|
-
* | roleName | String | Role name |
|
|
392
|
-
* | includeUserInfo? | boolean | should result including user info, by default: true |
|
|
393
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
394
|
-
|
|
395
|
-
* @returns
|
|
396
|
-
* | Property | Description |
|
|
397
|
-
* | :-- | :-- |
|
|
398
|
-
* | status | { error_code: number, reason: string } |
|
|
399
|
-
* | results | { users: {name: string}[]; role: {name: string} }[] |
|
|
400
|
-
*
|
|
401
|
-
* #### Example
|
|
402
|
-
*
|
|
403
|
-
* ```
|
|
404
|
-
* milvusClient.selectRole({roleName: 'myrole'});
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
User.prototype.selectRole = function (data) {
|
|
408
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
409
|
-
var promise;
|
|
410
|
-
return __generator(this, function (_a) {
|
|
411
|
-
switch (_a.label) {
|
|
412
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'SelectRole', {
|
|
413
|
-
role: { name: data.roleName },
|
|
414
|
-
include_user_info: data.includeUserInfo || true,
|
|
415
|
-
}, data.timeout || this.timeout)];
|
|
416
|
-
case 1:
|
|
417
|
-
promise = _a.sent();
|
|
418
|
-
return [2 /*return*/, promise];
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
};
|
|
423
|
-
/**
|
|
424
|
-
* list all roles
|
|
425
|
-
*
|
|
426
|
-
* @param data
|
|
427
|
-
* | Property | Type | Description |
|
|
428
|
-
* | :-- | :-- | :-- |
|
|
429
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
430
|
-
*
|
|
431
|
-
* @returns
|
|
432
|
-
* | Property | Description |
|
|
433
|
-
* | :-- | :-- |
|
|
434
|
-
* | status | { error_code: number, reason: string } |
|
|
435
|
-
* | reason | '' |
|
|
436
|
-
*
|
|
437
|
-
* #### Example
|
|
438
|
-
*
|
|
439
|
-
* ```
|
|
440
|
-
* milvusClient.listRoles();
|
|
441
|
-
* ```
|
|
442
|
-
*/
|
|
443
|
-
User.prototype.listRoles = function (data) {
|
|
444
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
445
|
-
var promise;
|
|
446
|
-
return __generator(this, function (_a) {
|
|
447
|
-
switch (_a.label) {
|
|
448
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'SelectRole', {}, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout)];
|
|
449
|
-
case 1:
|
|
450
|
-
promise = _a.sent();
|
|
451
|
-
return [2 /*return*/, promise];
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
};
|
|
456
|
-
/**
|
|
457
|
-
* gets all users that belong to a specified role
|
|
458
|
-
*
|
|
459
|
-
* @param data
|
|
460
|
-
* | Property | Type | Description |
|
|
461
|
-
* | :-- | :-- | :-- |
|
|
462
|
-
* | userName | String | User name |
|
|
463
|
-
* | includeUserInfo? | boolean | should result including user info, by default: true |
|
|
464
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
465
|
-
*
|
|
466
|
-
* @returns
|
|
467
|
-
* | Property | Description |
|
|
468
|
-
* | :-- | :-- |
|
|
469
|
-
* | status | { error_code: number, reason: string } |
|
|
470
|
-
* | results | user: {name: string}; roles: {name: string}[] |
|
|
471
|
-
*
|
|
472
|
-
* #### Example
|
|
473
|
-
*
|
|
474
|
-
* ```
|
|
475
|
-
* milvusClient.selectUser({username: 'name'});
|
|
476
|
-
* ```
|
|
477
|
-
*/
|
|
478
|
-
User.prototype.selectUser = function (data) {
|
|
479
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
480
|
-
var promise;
|
|
481
|
-
return __generator(this, function (_a) {
|
|
482
|
-
switch (_a.label) {
|
|
483
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'SelectUser', {
|
|
484
|
-
user: { name: data.username },
|
|
485
|
-
include_role_info: data.includeRoleInfo || true,
|
|
486
|
-
}, data.timeout || this.timeout)];
|
|
487
|
-
case 1:
|
|
488
|
-
promise = _a.sent();
|
|
489
|
-
return [2 /*return*/, promise];
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
};
|
|
494
|
-
/**
|
|
495
|
-
* grant privileges to a role
|
|
496
|
-
*
|
|
497
|
-
* @param data
|
|
498
|
-
* | Property | Type | Description |
|
|
499
|
-
* | :-- | :-- | :-- |
|
|
500
|
-
* | roleName | String | Role name |
|
|
501
|
-
* | object | string | Type of the operational object to which the specified privilege belongs, such as Collection, Index, Partition, etc. This parameter is case-sensitive.|
|
|
502
|
-
* | objectName | string | Name of the object to which the role is granted the specified prvilege. |
|
|
503
|
-
* | privilegeName | string | Name of the privilege to be granted to the role. This parameter is case-sensitive. |
|
|
504
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
505
|
-
*
|
|
506
|
-
* @returns
|
|
507
|
-
* | Property | Description |
|
|
508
|
-
* | :-- | :-- |
|
|
509
|
-
* | status | { error_code: number, reason: string } |
|
|
510
|
-
* | reason | '' |
|
|
511
|
-
*
|
|
512
|
-
* #### Example
|
|
513
|
-
*
|
|
514
|
-
* ```
|
|
515
|
-
* milvusClient.grantRolePrivilege({
|
|
516
|
-
* roleName: 'roleName',
|
|
517
|
-
* object: '*',
|
|
518
|
-
* objectName: 'Collection',
|
|
519
|
-
* privilegeName: 'CreateIndex'
|
|
520
|
-
* });
|
|
521
|
-
* ```
|
|
522
|
-
*/
|
|
523
|
-
User.prototype.grantRolePrivilege = function (data) {
|
|
524
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
525
|
-
var promise;
|
|
526
|
-
return __generator(this, function (_a) {
|
|
527
|
-
switch (_a.label) {
|
|
528
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'OperatePrivilege', {
|
|
529
|
-
entity: {
|
|
530
|
-
role: { name: data.roleName },
|
|
531
|
-
object: { name: data.object },
|
|
532
|
-
object_name: data.objectName,
|
|
533
|
-
grantor: {
|
|
534
|
-
privilege: { name: data.privilegeName },
|
|
535
|
-
},
|
|
536
|
-
},
|
|
537
|
-
type: _1.OperatePrivilegeType.Grant,
|
|
538
|
-
}, data.timeout || this.timeout)];
|
|
539
|
-
case 1:
|
|
540
|
-
promise = _a.sent();
|
|
541
|
-
return [2 /*return*/, promise];
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
};
|
|
546
|
-
/**
|
|
547
|
-
* revoke privileges to a role
|
|
548
|
-
*
|
|
549
|
-
* @param data
|
|
550
|
-
* | Property | Type | Description |
|
|
551
|
-
* | :-- | :-- | :-- |
|
|
552
|
-
* | roleName | String | Role name |
|
|
553
|
-
* | object | string | Type of the operational object to which the specified privilege belongs, such as Collection, Index, Partition, etc. This parameter is case-sensitive.|
|
|
554
|
-
* | objectName | string | Name of the object to which the role is granted the specified prvilege. |
|
|
555
|
-
* | privilegeName | string | Name of the privilege to be granted to the role. This parameter is case-sensitive. |
|
|
556
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
557
|
-
*
|
|
558
|
-
* @returns
|
|
559
|
-
* | Property | Description |
|
|
560
|
-
* | :------------- | :-------- |
|
|
561
|
-
* | status | { error_code: number, reason: string } |
|
|
562
|
-
* | reason | '' |
|
|
563
|
-
*
|
|
564
|
-
* #### Example
|
|
565
|
-
*
|
|
566
|
-
* ```
|
|
567
|
-
* milvusClient.grantRolePrivilege({
|
|
568
|
-
* roleName: 'roleName',
|
|
569
|
-
* object: '*',
|
|
570
|
-
* objectName: 'Collection',
|
|
571
|
-
* privilegeName: 'CreateIndex'
|
|
572
|
-
* });
|
|
573
|
-
* ```
|
|
574
|
-
*/
|
|
575
|
-
User.prototype.revokeRolePrivilege = function (data) {
|
|
576
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
577
|
-
var promise;
|
|
578
|
-
return __generator(this, function (_a) {
|
|
579
|
-
switch (_a.label) {
|
|
580
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'OperatePrivilege', {
|
|
581
|
-
entity: {
|
|
582
|
-
role: { name: data.roleName },
|
|
583
|
-
object: { name: data.object },
|
|
584
|
-
object_name: data.objectName,
|
|
585
|
-
grantor: {
|
|
586
|
-
privilege: { name: data.privilegeName },
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
type: _1.OperatePrivilegeType.Revoke,
|
|
590
|
-
}, data.timeout || this.timeout)];
|
|
591
|
-
case 1:
|
|
592
|
-
promise = _a.sent();
|
|
593
|
-
return [2 /*return*/, promise];
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
});
|
|
597
|
-
};
|
|
598
|
-
/**
|
|
599
|
-
* revoke all roles priviledges
|
|
600
|
-
* @param data
|
|
601
|
-
* | Property | Type | Description |
|
|
602
|
-
* | :-- | :-- | :-- |
|
|
603
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
604
|
-
*
|
|
605
|
-
* @returns
|
|
606
|
-
* | Property | Description |
|
|
607
|
-
* | :-- | :-- |
|
|
608
|
-
* | status | { error_code: number, reason: string } |
|
|
609
|
-
* | reason | '' |
|
|
610
|
-
*
|
|
611
|
-
* #### Example
|
|
612
|
-
*
|
|
613
|
-
* ```
|
|
614
|
-
* milvusClient.revokeAllRolesPrivileges();
|
|
615
|
-
* ```
|
|
616
|
-
*/
|
|
617
|
-
User.prototype.dropAllRoles = function (data) {
|
|
618
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
619
|
-
var res, promises, i, r, grants, j, entity, _a, _b;
|
|
620
|
-
return __generator(this, function (_c) {
|
|
621
|
-
switch (_c.label) {
|
|
622
|
-
case 0: return [4 /*yield*/, this.listRoles({ timeout: data === null || data === void 0 ? void 0 : data.timeout })];
|
|
623
|
-
case 1:
|
|
624
|
-
res = _c.sent();
|
|
625
|
-
promises = [];
|
|
626
|
-
i = 0;
|
|
627
|
-
_c.label = 2;
|
|
628
|
-
case 2:
|
|
629
|
-
if (!(i < res.results.length)) return [3 /*break*/, 10];
|
|
630
|
-
r = res.results[i];
|
|
631
|
-
return [4 /*yield*/, this.listGrants({
|
|
632
|
-
roleName: r.role.name,
|
|
633
|
-
})];
|
|
634
|
-
case 3:
|
|
635
|
-
grants = _c.sent();
|
|
636
|
-
j = 0;
|
|
637
|
-
_c.label = 4;
|
|
638
|
-
case 4:
|
|
639
|
-
if (!(j < grants.entities.length)) return [3 /*break*/, 7];
|
|
640
|
-
entity = grants.entities[j];
|
|
641
|
-
// revoke grant
|
|
642
|
-
return [4 /*yield*/, this.revokeRolePrivilege({
|
|
643
|
-
roleName: entity.role.name,
|
|
644
|
-
object: entity.object.name,
|
|
645
|
-
objectName: entity.object_name,
|
|
646
|
-
privilegeName: entity.grantor.privilege.name,
|
|
647
|
-
timeout: data === null || data === void 0 ? void 0 : data.timeout,
|
|
648
|
-
})];
|
|
649
|
-
case 5:
|
|
650
|
-
// revoke grant
|
|
651
|
-
_c.sent();
|
|
652
|
-
_c.label = 6;
|
|
653
|
-
case 6:
|
|
654
|
-
j++;
|
|
655
|
-
return [3 /*break*/, 4];
|
|
656
|
-
case 7:
|
|
657
|
-
_b = (_a = promises).push;
|
|
658
|
-
// drop the role
|
|
659
|
-
return [4 /*yield*/, this.dropRole({
|
|
660
|
-
roleName: r.role.name,
|
|
661
|
-
timeout: data === null || data === void 0 ? void 0 : data.timeout,
|
|
662
|
-
})];
|
|
663
|
-
case 8:
|
|
664
|
-
_b.apply(_a, [
|
|
665
|
-
// drop the role
|
|
666
|
-
_c.sent()]);
|
|
667
|
-
_c.label = 9;
|
|
668
|
-
case 9:
|
|
669
|
-
i++;
|
|
670
|
-
return [3 /*break*/, 2];
|
|
671
|
-
case 10: return [2 /*return*/, promises];
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
|
-
});
|
|
675
|
-
};
|
|
676
|
-
/**
|
|
677
|
-
* select a grant
|
|
678
|
-
* @param data
|
|
679
|
-
* | Property | Type | Description |
|
|
680
|
-
* | :-- | :-- | :-- |
|
|
681
|
-
* | roleName | String | Role name |
|
|
682
|
-
* | object | string | Type of the operational object to which the specified privilege belongs, such as Collection, Index, Partition, etc. This parameter is case-sensitive.|
|
|
683
|
-
* | objectName | string | Name of the object to which the role is granted the specified prvilege. |
|
|
684
|
-
* | privilegeName | string | Name of the privilege to be granted to the role. This parameter is case-sensitive. |
|
|
685
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
686
|
-
*
|
|
687
|
-
* @returns
|
|
688
|
-
* | Property | Description |
|
|
689
|
-
* | :-- | :-- |
|
|
690
|
-
* | status | { error_code: number, reason: string } |
|
|
691
|
-
* | reason | '' |
|
|
692
|
-
*
|
|
693
|
-
* #### Example
|
|
694
|
-
*
|
|
695
|
-
* ```
|
|
696
|
-
* milvusClient.selectGrant({
|
|
697
|
-
* roleName: 'roleName',
|
|
698
|
-
* object: '*',
|
|
699
|
-
* objectName: 'Collection',
|
|
700
|
-
* privilegeName: 'CreateIndex'
|
|
701
|
-
* });
|
|
702
|
-
* ```
|
|
703
|
-
*/
|
|
704
|
-
User.prototype.selectGrant = function (data) {
|
|
705
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
706
|
-
var promise;
|
|
707
|
-
return __generator(this, function (_a) {
|
|
708
|
-
switch (_a.label) {
|
|
709
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'SelectGrant', {
|
|
710
|
-
entity: {
|
|
711
|
-
role: { name: data.roleName },
|
|
712
|
-
object: { name: data.object },
|
|
713
|
-
object_name: data.objectName,
|
|
714
|
-
grantor: {
|
|
715
|
-
privilege: { name: data.privilegeName },
|
|
716
|
-
},
|
|
717
|
-
},
|
|
718
|
-
}, data.timeout || this.timeout)];
|
|
719
|
-
case 1:
|
|
720
|
-
promise = _a.sent();
|
|
721
|
-
return [2 /*return*/, promise];
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
});
|
|
725
|
-
};
|
|
726
|
-
/**
|
|
727
|
-
* list all grants for a role
|
|
728
|
-
* @param data
|
|
729
|
-
* | Property | Type | Description |
|
|
730
|
-
* | :-- | :-- | :-- |
|
|
731
|
-
* | roleName | String | Role name |
|
|
732
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
733
|
-
*
|
|
734
|
-
* @returns
|
|
735
|
-
* | Property | Description |
|
|
736
|
-
* | :-- | :-- |
|
|
737
|
-
* | status | { error_code: number, reason: string } |
|
|
738
|
-
* | reason | '' |
|
|
739
|
-
*
|
|
740
|
-
* #### Example
|
|
741
|
-
*
|
|
742
|
-
* ```
|
|
743
|
-
* milvusClient.listGrants({
|
|
744
|
-
* roleName: 'roleName',
|
|
745
|
-
* });
|
|
746
|
-
* ```
|
|
747
|
-
*/
|
|
748
|
-
User.prototype.listGrants = function (data) {
|
|
749
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
750
|
-
var promise;
|
|
751
|
-
return __generator(this, function (_a) {
|
|
752
|
-
switch (_a.label) {
|
|
753
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'SelectGrant', {
|
|
754
|
-
entity: {
|
|
755
|
-
role: { name: data.roleName },
|
|
756
|
-
},
|
|
757
|
-
}, data.timeout || this.timeout)];
|
|
758
|
-
case 1:
|
|
759
|
-
promise = _a.sent();
|
|
760
|
-
return [2 /*return*/, promise];
|
|
761
|
-
}
|
|
762
|
-
});
|
|
763
|
-
});
|
|
764
|
-
};
|
|
765
|
-
/**
|
|
766
|
-
* check if the role is existing
|
|
767
|
-
* @param data
|
|
768
|
-
* | Property | Type | Description |
|
|
769
|
-
* | :-- | :-- | :-- |
|
|
770
|
-
* | roleName | String | Role name |
|
|
771
|
-
* | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
|
|
772
|
-
*
|
|
773
|
-
* @returns
|
|
774
|
-
* | Property | Description |
|
|
775
|
-
* | :-- | :-- |
|
|
776
|
-
* | status | { error_code: number, reason: string } |
|
|
777
|
-
* | reason | '' |
|
|
778
|
-
*
|
|
779
|
-
* #### Example
|
|
780
|
-
*
|
|
781
|
-
* ```
|
|
782
|
-
* milvusClient.hasRole({
|
|
783
|
-
* roleName: 'roleName',
|
|
784
|
-
* });
|
|
785
|
-
* ```
|
|
786
|
-
*/
|
|
787
|
-
User.prototype.hasRole = function (data) {
|
|
788
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
789
|
-
var result;
|
|
790
|
-
return __generator(this, function (_a) {
|
|
791
|
-
switch (_a.label) {
|
|
792
|
-
case 0: return [4 /*yield*/, this.listRoles()];
|
|
793
|
-
case 1:
|
|
794
|
-
result = _a.sent();
|
|
795
|
-
return [2 /*return*/, {
|
|
796
|
-
status: result.status,
|
|
797
|
-
hasRole: result.results.map(function (r) { return r.role.name; }).includes(data.roleName),
|
|
798
|
-
}];
|
|
799
|
-
}
|
|
800
|
-
});
|
|
801
|
-
});
|
|
802
|
-
};
|
|
803
|
-
return User;
|
|
804
|
-
}(Resource_1.Resource));
|
|
805
|
-
exports.User = User;
|
|
806
|
-
//# sourceMappingURL=User.js.map
|