@routr/ctl 2.15.4 → 2.16.0
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 +170 -120
- package/bin/dev +12 -12
- package/bin/run +5 -3
- package/dist/base.d.ts +3 -3
- package/dist/base.js +1 -1
- package/dist/commands/acl/create.js +7 -7
- package/dist/commands/acl/delete.d.ts +1 -1
- package/dist/commands/acl/delete.js +6 -6
- package/dist/commands/acl/describe.d.ts +2 -4
- package/dist/commands/acl/describe.js +5 -9
- package/dist/commands/acl/get.d.ts +6 -8
- package/dist/commands/acl/get.js +9 -10
- package/dist/commands/acl/update.d.ts +2 -4
- package/dist/commands/acl/update.js +8 -8
- package/dist/commands/agents/create.js +7 -7
- package/dist/commands/agents/delete.js +1 -1
- package/dist/commands/agents/describe.d.ts +2 -4
- package/dist/commands/agents/describe.js +5 -9
- package/dist/commands/agents/get.d.ts +6 -8
- package/dist/commands/agents/get.js +9 -10
- package/dist/commands/agents/update.d.ts +2 -4
- package/dist/commands/agents/update.js +11 -12
- package/dist/commands/credentials/create.js +7 -7
- package/dist/commands/credentials/delete.js +1 -1
- package/dist/commands/credentials/describe.d.ts +2 -4
- package/dist/commands/credentials/describe.js +6 -7
- package/dist/commands/credentials/get.d.ts +6 -8
- package/dist/commands/credentials/get.js +9 -10
- package/dist/commands/credentials/update.d.ts +2 -4
- package/dist/commands/credentials/update.js +9 -10
- package/dist/commands/domains/create.js +7 -7
- package/dist/commands/domains/delete.js +1 -1
- package/dist/commands/domains/describe.d.ts +2 -4
- package/dist/commands/domains/describe.js +6 -7
- package/dist/commands/domains/get.d.ts +6 -8
- package/dist/commands/domains/get.js +9 -10
- package/dist/commands/domains/update.d.ts +2 -4
- package/dist/commands/domains/update.js +10 -11
- package/dist/commands/numbers/create.js +7 -7
- package/dist/commands/numbers/delete.js +1 -1
- package/dist/commands/numbers/describe.d.ts +2 -4
- package/dist/commands/numbers/describe.js +6 -7
- package/dist/commands/numbers/get.d.ts +6 -8
- package/dist/commands/numbers/get.js +9 -10
- package/dist/commands/numbers/update.d.ts +2 -4
- package/dist/commands/numbers/update.js +10 -11
- package/dist/commands/peers/create.js +7 -7
- package/dist/commands/peers/delete.js +1 -1
- package/dist/commands/peers/describe.d.ts +2 -4
- package/dist/commands/peers/describe.js +5 -9
- package/dist/commands/peers/get.d.ts +6 -8
- package/dist/commands/peers/get.js +9 -10
- package/dist/commands/peers/update.d.ts +2 -4
- package/dist/commands/peers/update.js +11 -12
- package/dist/commands/trunks/create.js +7 -7
- package/dist/commands/trunks/delete.js +1 -1
- package/dist/commands/trunks/describe.d.ts +2 -4
- package/dist/commands/trunks/describe.js +5 -9
- package/dist/commands/trunks/get.d.ts +6 -8
- package/dist/commands/trunks/get.js +9 -10
- package/dist/commands/trunks/update.d.ts +2 -4
- package/dist/commands/trunks/update.js +12 -13
- package/dist/delete.d.ts +2 -2
- package/dist/delete.js +10 -8
- package/dist/help.js +2 -1
- package/dist/lib/table.d.ts +15 -0
- package/dist/lib/table.js +75 -0
- package/dist/lib/wait.d.ts +1 -0
- package/dist/lib/wait.js +25 -0
- package/oclif.manifest.json +1164 -765
- package/package.json +15 -14
package/bin/dev
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const path = require("path")
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// In dev mode -> use ts-node to run commands straight from src.
|
|
6
|
+
process.env.NODE_ENV = "development"
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
require("ts-node").register({
|
|
9
|
+
project: path.join(__dirname, "..", "tsconfig.json")
|
|
10
|
+
})
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
oclif.settings.debug = true
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
|
12
|
+
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
13
|
+
;(async () => {
|
|
14
|
+
const oclif = await import("@oclif/core")
|
|
15
|
+
oclif.settings.debug = true
|
|
16
|
+
await oclif.execute({ development: true, dir: __dirname })
|
|
17
|
+
})()
|
package/bin/run
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
oclif
|
|
3
|
+
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
4
|
+
(async () => {
|
|
5
|
+
const oclif = await import("@oclif/core")
|
|
6
|
+
await oclif.execute({ dir: __dirname })
|
|
7
|
+
})()
|
package/dist/base.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
export declare abstract class BaseCommand extends Command {
|
|
3
|
-
static readonly
|
|
3
|
+
static readonly baseFlags: {
|
|
4
4
|
insecure: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
5
|
-
cacert: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
6
|
-
endpoint: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
5
|
+
cacert: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
endpoint: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
7
|
};
|
|
8
8
|
}
|
package/dist/base.js
CHANGED
|
@@ -24,7 +24,7 @@ const core_1 = require("@oclif/core");
|
|
|
24
24
|
class BaseCommand extends core_1.Command {
|
|
25
25
|
}
|
|
26
26
|
exports.BaseCommand = BaseCommand;
|
|
27
|
-
BaseCommand.
|
|
27
|
+
BaseCommand.baseFlags = {
|
|
28
28
|
insecure: core_1.Flags.boolean({
|
|
29
29
|
char: "i",
|
|
30
30
|
description: "allow insecure connections to the routr server",
|
|
@@ -55,10 +55,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
55
55
|
* limitations under the License.
|
|
56
56
|
*/
|
|
57
57
|
/* eslint-disable require-jsdoc */
|
|
58
|
-
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
59
58
|
const core_1 = require("@oclif/core");
|
|
59
|
+
const wait_1 = require("../../lib/wait");
|
|
60
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
60
61
|
const base_1 = require("../../base");
|
|
61
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
62
62
|
const validators_1 = require("../../validators");
|
|
63
63
|
const utils_1 = require("../../utils");
|
|
64
64
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
@@ -105,19 +105,19 @@ class CreateCommand extends base_1.BaseCommand {
|
|
|
105
105
|
this.warn("Aborted");
|
|
106
106
|
}
|
|
107
107
|
else {
|
|
108
|
-
core_1.
|
|
108
|
+
core_1.ux.action.start(`Creating ACL ${answers.name}`);
|
|
109
109
|
const api = new sdk_1.default.Acls({ endpoint, insecure, cacert });
|
|
110
110
|
const acl = await api.createAcl(answers);
|
|
111
|
-
await
|
|
112
|
-
core_1.
|
|
111
|
+
await (0, wait_1.wait)(1000);
|
|
112
|
+
core_1.ux.action.stop(acl.ref);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
catch (e) {
|
|
116
116
|
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
117
|
-
throw new
|
|
117
|
+
throw new core_1.Errors.CLIError("This ACL already exist");
|
|
118
118
|
}
|
|
119
119
|
else {
|
|
120
|
-
throw new
|
|
120
|
+
throw new core_1.Errors.CLIError(e.message);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DeleteCommand from "../../delete";
|
|
2
|
-
export default class
|
|
2
|
+
export default class DeleteAclCommand extends DeleteCommand {
|
|
3
3
|
static readonly description = "Deletes an Access Control List";
|
|
4
4
|
static readonly examples: string[];
|
|
5
5
|
run(): Promise<void>;
|
|
@@ -24,17 +24,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
/* eslint-disable require-jsdoc */
|
|
25
25
|
const delete_1 = __importDefault(require("../../delete"));
|
|
26
26
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
27
|
-
class
|
|
27
|
+
class DeleteAclCommand extends delete_1.default {
|
|
28
28
|
async run() {
|
|
29
|
-
const { flags } = await this.parse(
|
|
29
|
+
const { flags } = await this.parse(delete_1.default);
|
|
30
30
|
const { endpoint, insecure, cacert } = flags;
|
|
31
|
-
await super.deleteResource(new sdk_1.default.Acls({ endpoint, insecure, cacert }), "
|
|
31
|
+
await super.deleteResource(new sdk_1.default.Acls({ endpoint, insecure, cacert }), "deleteAcl");
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
DeleteAclCommand.description = "Deletes an Access Control List";
|
|
35
|
+
DeleteAclCommand.examples = [
|
|
36
36
|
`<%= config.bin %> <%= command.id %>
|
|
37
37
|
Deleting item 80181ca6-d4aa-4575-9375-8f72b071111... Done
|
|
38
38
|
`
|
|
39
39
|
];
|
|
40
|
-
exports.default =
|
|
40
|
+
exports.default = DeleteAclCommand;
|
|
@@ -2,9 +2,7 @@ import { BaseCommand } from "../../base";
|
|
|
2
2
|
export default class DescribeCommand extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static args: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
description: string;
|
|
8
|
-
}[];
|
|
5
|
+
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
9
7
|
run(): Promise<void>;
|
|
10
8
|
}
|
|
@@ -22,8 +22,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
* limitations under the License.
|
|
23
23
|
*/
|
|
24
24
|
/* eslint-disable require-jsdoc */
|
|
25
|
+
const core_1 = require("@oclif/core");
|
|
25
26
|
const base_1 = require("../../base");
|
|
26
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
27
27
|
const prettyjson_1 = require("prettyjson");
|
|
28
28
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
29
29
|
const moment_1 = __importDefault(require("moment"));
|
|
@@ -47,16 +47,12 @@ class DescribeCommand extends base_1.BaseCommand {
|
|
|
47
47
|
this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
48
48
|
}
|
|
49
49
|
catch (e) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new core_1.Errors.CLIError(e.message);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
DescribeCommand.description = "shows details of an ACL";
|
|
55
|
-
DescribeCommand.args =
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
required: false,
|
|
59
|
-
description: "reference to the ACL"
|
|
60
|
-
}
|
|
61
|
-
];
|
|
55
|
+
DescribeCommand.args = {
|
|
56
|
+
ref: core_1.Args.string({ required: false, description: "reference to the ACL" })
|
|
57
|
+
};
|
|
62
58
|
exports.default = DescribeCommand;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
+
import { Interfaces } from "@oclif/core";
|
|
1
2
|
import { BaseCommand } from "../../base";
|
|
2
|
-
import { CommandError } from "@oclif/core/lib/interfaces";
|
|
3
3
|
export default class GetCommand extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
-
size:
|
|
8
|
-
extended:
|
|
7
|
+
size: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
8
|
+
extended: Interfaces.BooleanFlag<boolean>;
|
|
9
9
|
};
|
|
10
10
|
static args: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
description: string;
|
|
14
|
-
}[];
|
|
11
|
+
ref: Interfaces.Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
15
13
|
run(): Promise<void>;
|
|
16
14
|
catch(error: {
|
|
17
15
|
code: number;
|
|
18
16
|
message: string;
|
|
19
|
-
} | CommandError): Promise<void>;
|
|
17
|
+
} | Interfaces.CommandError): Promise<void>;
|
|
20
18
|
}
|
package/dist/commands/acl/get.js
CHANGED
|
@@ -52,18 +52,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
52
52
|
* limitations under the License.
|
|
53
53
|
*/
|
|
54
54
|
/* eslint-disable require-jsdoc */
|
|
55
|
-
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
56
55
|
const core_1 = require("@oclif/core");
|
|
56
|
+
const table_1 = require("../../lib/table");
|
|
57
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
57
58
|
const base_1 = require("../../base");
|
|
58
59
|
const utils_1 = require("../../utils");
|
|
59
60
|
const common_1 = require("@routr/common");
|
|
60
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
61
61
|
class GetCommand extends base_1.BaseCommand {
|
|
62
62
|
async run() {
|
|
63
63
|
const { args, flags } = await this.parse(GetCommand);
|
|
64
64
|
const showTable = (request) => {
|
|
65
65
|
const { showHeader, data, self, flags } = request;
|
|
66
|
-
|
|
66
|
+
(0, table_1.printTable)(data, {
|
|
67
67
|
ref: {
|
|
68
68
|
minWidth: 7,
|
|
69
69
|
extended: true
|
|
@@ -97,9 +97,9 @@ class GetCommand extends base_1.BaseCommand {
|
|
|
97
97
|
// To be handled globally
|
|
98
98
|
if ("code" in error && error.code === grpc.status.NOT_FOUND) {
|
|
99
99
|
const { args } = await this.parse(GetCommand);
|
|
100
|
-
throw new
|
|
100
|
+
throw new core_1.Errors.CLIError("the ACL you are looking for does not exist: " + args.ref);
|
|
101
101
|
}
|
|
102
|
-
throw new
|
|
102
|
+
throw new core_1.Errors.CLIError(error.message);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
GetCommand.description = "Shows a list of paginated ACLs or a single ACL if a ref is provided";
|
|
@@ -120,11 +120,10 @@ GetCommand.flags = {
|
|
|
120
120
|
description: "extended output format"
|
|
121
121
|
})
|
|
122
122
|
};
|
|
123
|
-
GetCommand.args =
|
|
124
|
-
{
|
|
125
|
-
name: "ref",
|
|
123
|
+
GetCommand.args = {
|
|
124
|
+
ref: core_1.Args.string({
|
|
126
125
|
required: false,
|
|
127
126
|
description: "optional reference to an ACL"
|
|
128
|
-
}
|
|
129
|
-
|
|
127
|
+
})
|
|
128
|
+
};
|
|
130
129
|
exports.default = GetCommand;
|
|
@@ -3,9 +3,7 @@ export default class UpdateCommand extends BaseCommand {
|
|
|
3
3
|
static readonly description = "Updates an existing ACL";
|
|
4
4
|
static readonly examples: string[];
|
|
5
5
|
static readonly args: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
description: string;
|
|
9
|
-
}[];
|
|
6
|
+
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
10
8
|
run(): Promise<void>;
|
|
11
9
|
}
|
|
@@ -23,8 +23,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
*/
|
|
24
24
|
/* eslint-disable require-jsdoc */
|
|
25
25
|
const core_1 = require("@oclif/core");
|
|
26
|
+
const wait_1 = require("../../lib/wait");
|
|
26
27
|
const base_1 = require("../../base");
|
|
27
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
28
28
|
const validators_1 = require("../../validators");
|
|
29
29
|
const utils_1 = require("../../utils");
|
|
30
30
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
@@ -76,14 +76,14 @@ class UpdateCommand extends base_1.BaseCommand {
|
|
|
76
76
|
this.warn("Aborted");
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
|
-
core_1.
|
|
79
|
+
core_1.ux.action.start(`Updating ACL ${answers.name}`);
|
|
80
80
|
const acl = await api.updateAcl(answers);
|
|
81
|
-
await
|
|
82
|
-
core_1.
|
|
81
|
+
await (0, wait_1.wait)(1000);
|
|
82
|
+
core_1.ux.action.stop(acl.ref);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
catch (e) {
|
|
86
|
-
throw new
|
|
86
|
+
throw new core_1.Errors.CLIError(e.message);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -93,7 +93,7 @@ UpdateCommand.examples = [
|
|
|
93
93
|
Updating ACL US East... 80181ca6-d4aa-4575-9375-8f72b07d5555
|
|
94
94
|
`
|
|
95
95
|
];
|
|
96
|
-
UpdateCommand.args =
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
UpdateCommand.args = {
|
|
97
|
+
ref: core_1.Args.string({ required: true, description: "reference to an ACL" })
|
|
98
|
+
};
|
|
99
99
|
exports.default = UpdateCommand;
|
|
@@ -55,10 +55,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
55
55
|
* limitations under the License.
|
|
56
56
|
*/
|
|
57
57
|
/* eslint-disable require-jsdoc */
|
|
58
|
-
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
59
58
|
const core_1 = require("@oclif/core");
|
|
59
|
+
const wait_1 = require("../../lib/wait");
|
|
60
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
60
61
|
const base_1 = require("../../base");
|
|
61
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
62
62
|
const common_1 = require("@routr/common");
|
|
63
63
|
const validators_1 = require("../../validators");
|
|
64
64
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
@@ -166,22 +166,22 @@ class CreateAgentCommand extends base_1.BaseCommand {
|
|
|
166
166
|
this.warn("Aborted");
|
|
167
167
|
}
|
|
168
168
|
else {
|
|
169
|
-
core_1.
|
|
169
|
+
core_1.ux.action.start(`Creating Agent ${answers.name}`);
|
|
170
170
|
const api = new sdk_1.default.Agents({ endpoint, insecure, cacert });
|
|
171
171
|
answers.maxContacts = answers.maxContacts
|
|
172
172
|
? parseInt(answers.maxContacts)
|
|
173
173
|
: -1;
|
|
174
174
|
const agent = await api.createAgent(answers);
|
|
175
|
-
await
|
|
176
|
-
core_1.
|
|
175
|
+
await (0, wait_1.wait)(1000);
|
|
176
|
+
core_1.ux.action.stop(agent.ref);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
catch (e) {
|
|
180
180
|
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
181
|
-
throw new
|
|
181
|
+
throw new core_1.Errors.CLIError("This Agent already exist");
|
|
182
182
|
}
|
|
183
183
|
else {
|
|
184
|
-
throw new
|
|
184
|
+
throw new core_1.Errors.CLIError(e.message);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -26,7 +26,7 @@ const delete_1 = __importDefault(require("../../delete"));
|
|
|
26
26
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
27
27
|
class DeleteAgentCommand extends delete_1.default {
|
|
28
28
|
async run() {
|
|
29
|
-
const { flags } = await this.parse(
|
|
29
|
+
const { flags } = await this.parse(delete_1.default);
|
|
30
30
|
const { endpoint, insecure, cacert } = flags;
|
|
31
31
|
await super.deleteResource(new sdk_1.default.Agents({ endpoint, insecure, cacert }), "deleteAgent");
|
|
32
32
|
}
|
|
@@ -2,9 +2,7 @@ import { BaseCommand } from "../../base";
|
|
|
2
2
|
export default class DescribeCommand extends BaseCommand {
|
|
3
3
|
static readonly description = "shows details of an Agent";
|
|
4
4
|
static readonly args: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
description: string;
|
|
8
|
-
}[];
|
|
5
|
+
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
9
7
|
run(): Promise<void>;
|
|
10
8
|
}
|
|
@@ -22,8 +22,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
* limitations under the License.
|
|
23
23
|
*/
|
|
24
24
|
/* eslint-disable require-jsdoc */
|
|
25
|
+
const core_1 = require("@oclif/core");
|
|
25
26
|
const base_1 = require("../../base");
|
|
26
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
27
27
|
const prettyjson_1 = require("prettyjson");
|
|
28
28
|
const utils_1 = require("../../utils");
|
|
29
29
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
@@ -58,16 +58,12 @@ class DescribeCommand extends base_1.BaseCommand {
|
|
|
58
58
|
this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
59
59
|
}
|
|
60
60
|
catch (e) {
|
|
61
|
-
throw new
|
|
61
|
+
throw new core_1.Errors.CLIError(e.message);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
DescribeCommand.description = "shows details of an Agent";
|
|
66
|
-
DescribeCommand.args =
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
required: false,
|
|
70
|
-
description: "reference to the Agent"
|
|
71
|
-
}
|
|
72
|
-
];
|
|
66
|
+
DescribeCommand.args = {
|
|
67
|
+
ref: core_1.Args.string({ required: false, description: "reference to the Agent" })
|
|
68
|
+
};
|
|
73
69
|
exports.default = DescribeCommand;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
+
import { Interfaces } from "@oclif/core";
|
|
1
2
|
import { BaseCommand } from "../../base";
|
|
2
|
-
import { CommandError } from "@oclif/core/lib/interfaces";
|
|
3
3
|
export default class GetAgentsCommand extends BaseCommand {
|
|
4
4
|
static readonly description = "Shows a list of paginated Agents or a single Agent if ref is provided";
|
|
5
5
|
static readonly examples: string[];
|
|
6
6
|
static readonly flags: {
|
|
7
|
-
size:
|
|
8
|
-
extended:
|
|
7
|
+
size: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
8
|
+
extended: Interfaces.BooleanFlag<boolean>;
|
|
9
9
|
};
|
|
10
10
|
static args: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
description: string;
|
|
14
|
-
}[];
|
|
11
|
+
ref: Interfaces.Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
15
13
|
run(): Promise<void>;
|
|
16
14
|
catch(error: {
|
|
17
15
|
code: number;
|
|
18
16
|
message: string;
|
|
19
|
-
} | CommandError): Promise<void>;
|
|
17
|
+
} | Interfaces.CommandError): Promise<void>;
|
|
20
18
|
}
|
|
@@ -52,18 +52,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
52
52
|
* limitations under the License.
|
|
53
53
|
*/
|
|
54
54
|
/* eslint-disable require-jsdoc */
|
|
55
|
-
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
56
55
|
const core_1 = require("@oclif/core");
|
|
56
|
+
const table_1 = require("../../lib/table");
|
|
57
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
57
58
|
const base_1 = require("../../base");
|
|
58
59
|
const utils_1 = require("../../utils");
|
|
59
60
|
const common_1 = require("@routr/common");
|
|
60
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
61
61
|
class GetAgentsCommand extends base_1.BaseCommand {
|
|
62
62
|
async run() {
|
|
63
63
|
const { args, flags } = await this.parse(GetAgentsCommand);
|
|
64
64
|
const showTable = (request) => {
|
|
65
65
|
const { showHeader, data, self, flags } = request;
|
|
66
|
-
|
|
66
|
+
(0, table_1.printTable)(data, {
|
|
67
67
|
ref: {
|
|
68
68
|
minWidth: 7,
|
|
69
69
|
extended: true
|
|
@@ -108,9 +108,9 @@ class GetAgentsCommand extends base_1.BaseCommand {
|
|
|
108
108
|
// To be handled globally
|
|
109
109
|
if ("code" in error && error.code === grpc.status.NOT_FOUND) {
|
|
110
110
|
const { args } = await this.parse(GetAgentsCommand);
|
|
111
|
-
throw new
|
|
111
|
+
throw new core_1.Errors.CLIError("the Agent you are looking for does not exist: " + args.ref);
|
|
112
112
|
}
|
|
113
|
-
throw new
|
|
113
|
+
throw new core_1.Errors.CLIError(error.message);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
GetAgentsCommand.description = "Shows a list of paginated Agents or a single Agent if ref is provided";
|
|
@@ -131,11 +131,10 @@ GetAgentsCommand.flags = {
|
|
|
131
131
|
description: "extended output format"
|
|
132
132
|
})
|
|
133
133
|
};
|
|
134
|
-
GetAgentsCommand.args =
|
|
135
|
-
{
|
|
136
|
-
name: "ref",
|
|
134
|
+
GetAgentsCommand.args = {
|
|
135
|
+
ref: core_1.Args.string({
|
|
137
136
|
required: false,
|
|
138
137
|
description: "Optional Agents reference"
|
|
139
|
-
}
|
|
140
|
-
|
|
138
|
+
})
|
|
139
|
+
};
|
|
141
140
|
exports.default = GetAgentsCommand;
|
|
@@ -3,9 +3,7 @@ export default class UpdateCommand extends BaseCommand {
|
|
|
3
3
|
static readonly description = "Updates an existing Agent";
|
|
4
4
|
static readonly examples: string[];
|
|
5
5
|
static readonly args: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
description: string;
|
|
9
|
-
}[];
|
|
6
|
+
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
10
8
|
run(): Promise<void>;
|
|
11
9
|
}
|
|
@@ -23,8 +23,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
*/
|
|
24
24
|
/* eslint-disable require-jsdoc */
|
|
25
25
|
const core_1 = require("@oclif/core");
|
|
26
|
+
const wait_1 = require("../../lib/wait");
|
|
26
27
|
const base_1 = require("../../base");
|
|
27
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
28
28
|
const common_1 = require("@routr/common");
|
|
29
29
|
const validators_1 = require("../../validators");
|
|
30
30
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
@@ -76,14 +76,14 @@ class UpdateCommand extends base_1.BaseCommand {
|
|
|
76
76
|
{
|
|
77
77
|
name: "domainRef",
|
|
78
78
|
message: "Select a Domain",
|
|
79
|
-
choices: [{ name: "None", value:
|
|
79
|
+
choices: [{ name: "None", value: "" }, ...domainsList],
|
|
80
80
|
type: "list"
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
name: "credentialsRef",
|
|
84
84
|
message: "Credentials Name",
|
|
85
85
|
type: "list",
|
|
86
|
-
choices: [{ name: "None", value:
|
|
86
|
+
choices: [{ name: "None", value: "" }, ...credentialsList],
|
|
87
87
|
default: agentFromDB.credentialsRef
|
|
88
88
|
},
|
|
89
89
|
{
|
|
@@ -132,14 +132,14 @@ class UpdateCommand extends base_1.BaseCommand {
|
|
|
132
132
|
this.warn("Aborted");
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
|
-
core_1.
|
|
135
|
+
core_1.ux.action.start(`Updating Agent ${answers.name}`);
|
|
136
136
|
const agent = await api.updateAgent(answers);
|
|
137
|
-
await
|
|
138
|
-
core_1.
|
|
137
|
+
await (0, wait_1.wait)(1000);
|
|
138
|
+
core_1.ux.action.stop(agent.ref);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
catch (e) {
|
|
142
|
-
throw new
|
|
142
|
+
throw new core_1.Errors.CLIError(e.message);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -149,11 +149,10 @@ UpdateCommand.examples = [
|
|
|
149
149
|
Updating Agent John Doe... 80181ca6-d4aa-4575-9375-8f72b07d5555
|
|
150
150
|
`
|
|
151
151
|
];
|
|
152
|
-
UpdateCommand.args =
|
|
153
|
-
{
|
|
154
|
-
name: "ref",
|
|
152
|
+
UpdateCommand.args = {
|
|
153
|
+
ref: core_1.Args.string({
|
|
155
154
|
required: true,
|
|
156
155
|
description: "reference to an existing Agent"
|
|
157
|
-
}
|
|
158
|
-
|
|
156
|
+
})
|
|
157
|
+
};
|
|
159
158
|
exports.default = UpdateCommand;
|
|
@@ -55,10 +55,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
55
55
|
* limitations under the License.
|
|
56
56
|
*/
|
|
57
57
|
/* eslint-disable require-jsdoc */
|
|
58
|
-
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
59
58
|
const core_1 = require("@oclif/core");
|
|
59
|
+
const wait_1 = require("../../lib/wait");
|
|
60
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
60
61
|
const base_1 = require("../../base");
|
|
61
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
62
62
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
63
63
|
// NOTE: Newer versions of inquirer have a bug that causes the following error:
|
|
64
64
|
// (node:75345) [ERR_REQUIRE_ESM] Error Plugin: @routr/ctl [ERR_REQUIRE_ESM]: require() of ES Module
|
|
@@ -105,18 +105,18 @@ class CreateCommand extends base_1.BaseCommand {
|
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
107
|
try {
|
|
108
|
-
core_1.
|
|
108
|
+
core_1.ux.action.start(`Creating Credentials ${answers.name}`);
|
|
109
109
|
const api = new sdk_1.default.Credentials({ endpoint, insecure, cacert });
|
|
110
110
|
const credentials = await api.createCredentials(answers);
|
|
111
|
-
await
|
|
112
|
-
core_1.
|
|
111
|
+
await (0, wait_1.wait)(1000);
|
|
112
|
+
core_1.ux.action.stop(credentials.ref);
|
|
113
113
|
}
|
|
114
114
|
catch (e) {
|
|
115
115
|
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
116
|
-
throw new
|
|
116
|
+
throw new core_1.Errors.CLIError("This Credentials already exist");
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
119
|
-
throw new
|
|
119
|
+
throw new core_1.Errors.CLIError(e.message);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -26,7 +26,7 @@ const delete_1 = __importDefault(require("../../delete"));
|
|
|
26
26
|
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
27
27
|
class DeleteCredentialsCommand extends delete_1.default {
|
|
28
28
|
async run() {
|
|
29
|
-
const { flags } = await this.parse(
|
|
29
|
+
const { flags } = await this.parse(delete_1.default);
|
|
30
30
|
const { endpoint, insecure, cacert } = flags;
|
|
31
31
|
await super.deleteResource(new sdk_1.default.Credentials({ endpoint, insecure, cacert }), "deleteCredentials");
|
|
32
32
|
}
|
|
@@ -2,9 +2,7 @@ import { BaseCommand } from "../../base";
|
|
|
2
2
|
export default class DescribeCommand extends BaseCommand {
|
|
3
3
|
static readonly description = "shows details for a set of Credentials";
|
|
4
4
|
static readonly args: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
description: string;
|
|
8
|
-
}[];
|
|
5
|
+
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
9
7
|
run(): Promise<void>;
|
|
10
8
|
}
|