@routr/ctl 2.0.8-alpha.23 → 2.0.8-alpha.25
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 -51
- package/dist/base.d.ts +0 -1
- package/dist/base.js +0 -4
- package/dist/commands/acl/create.js +43 -43
- package/dist/commands/acl/describe.d.ts +10 -0
- package/dist/commands/acl/describe.js +62 -0
- package/dist/commands/acl/get.d.ts +1 -0
- package/dist/commands/acl/get.js +5 -20
- package/dist/commands/acl/update.js +43 -43
- package/dist/commands/agents/create.js +97 -97
- package/dist/commands/agents/describe.d.ts +10 -0
- package/dist/commands/agents/describe.js +72 -0
- package/dist/commands/agents/get.d.ts +1 -0
- package/dist/commands/agents/get.js +4 -26
- package/dist/commands/agents/update.js +88 -88
- package/dist/commands/credentials/describe.d.ts +10 -0
- package/dist/commands/credentials/describe.js +61 -0
- package/dist/commands/credentials/get.d.ts +1 -0
- package/dist/commands/credentials/get.js +5 -20
- package/dist/commands/credentials/update.js +39 -39
- package/dist/commands/domains/create.js +105 -105
- package/dist/commands/domains/describe.d.ts +10 -0
- package/dist/commands/domains/describe.js +78 -0
- package/dist/commands/domains/get.d.ts +1 -0
- package/dist/commands/domains/get.js +4 -24
- package/dist/commands/domains/update.js +99 -99
- package/dist/commands/numbers/create.js +88 -88
- package/dist/commands/numbers/describe.d.ts +10 -0
- package/dist/commands/numbers/describe.js +72 -0
- package/dist/commands/numbers/get.d.ts +1 -0
- package/dist/commands/numbers/get.js +4 -24
- package/dist/commands/numbers/update.js +69 -69
- package/dist/commands/peers/create.js +106 -97
- package/dist/commands/peers/describe.d.ts +10 -0
- package/dist/commands/peers/describe.js +80 -0
- package/dist/commands/peers/get.d.ts +1 -0
- package/dist/commands/peers/get.js +6 -43
- package/dist/commands/peers/update.js +103 -94
- package/dist/commands/trunks/create.js +143 -139
- package/dist/commands/trunks/describe.d.ts +10 -0
- package/dist/commands/trunks/describe.js +85 -0
- package/dist/commands/trunks/get.d.ts +1 -0
- package/dist/commands/trunks/get.js +6 -33
- package/dist/commands/trunks/update.js +146 -142
- package/dist/delete.js +8 -3
- package/oclif.manifest.json +267 -183
- package/package.json +8 -5
|
@@ -59,56 +59,56 @@ class CreateCommand extends base_1.BaseCommand {
|
|
|
59
59
|
async run() {
|
|
60
60
|
const { flags } = await this.parse(CreateCommand);
|
|
61
61
|
const { endpoint, insecure } = flags;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
62
|
+
try {
|
|
63
|
+
this.log("This utility will help you create a new ACL");
|
|
64
|
+
this.log("Press ^C at any time to quit.");
|
|
65
|
+
const answers = await inquirer_1.default.prompt([
|
|
66
|
+
{
|
|
67
|
+
name: "name",
|
|
68
|
+
message: "Friendly Name",
|
|
69
|
+
type: "input",
|
|
70
|
+
validate: validators_1.nameValidator
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "deny",
|
|
74
|
+
message: "Deny CIDR Networks",
|
|
75
|
+
type: "input",
|
|
76
|
+
default: "0.0.0.0/0",
|
|
77
|
+
validate: validators_1.aclRuleValidator
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "allow",
|
|
81
|
+
message: "Allow CIDR Networks",
|
|
82
|
+
type: "input",
|
|
83
|
+
validate: validators_1.aclRuleValidator
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "confirm",
|
|
87
|
+
message: "Ready?",
|
|
88
|
+
type: "confirm"
|
|
89
|
+
}
|
|
90
|
+
]);
|
|
91
|
+
// Re-assign allow and deny rules as arrays
|
|
92
|
+
answers.allow = (0, utils_1.stringToACL)(answers.allow);
|
|
93
|
+
answers.deny = (0, utils_1.stringToACL)(answers.deny);
|
|
94
|
+
if (!answers.confirm) {
|
|
95
|
+
this.warn("Aborted");
|
|
88
96
|
}
|
|
89
|
-
|
|
90
|
-
// Re-assign allow and deny rules as arrays
|
|
91
|
-
answers.allow = (0, utils_1.stringToACL)(answers.allow);
|
|
92
|
-
answers.deny = (0, utils_1.stringToACL)(answers.deny);
|
|
93
|
-
if (!answers.confirm) {
|
|
94
|
-
this.warn("Aborted");
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
try {
|
|
97
|
+
else {
|
|
98
98
|
core_1.CliUx.ux.action.start(`Creating ACL ${answers.name}`);
|
|
99
99
|
const api = new sdk_1.default.ACL({ endpoint, insecure });
|
|
100
100
|
const acl = await api.createACL(answers);
|
|
101
101
|
await core_1.CliUx.ux.wait(1000);
|
|
102
102
|
core_1.CliUx.ux.action.stop(acl.ref);
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
core_1.CliUx.ux.action.stop();
|
|
107
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
108
|
+
throw new errors_1.CLIError("This ACL already exist");
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
throw new errors_1.CLIError(e.message);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
8
|
+
* http://github.com/fonoster
|
|
9
|
+
*
|
|
10
|
+
* This file is part of Routr.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the MIT License (the "License");
|
|
13
|
+
* you may not use this file except in compliance with
|
|
14
|
+
* the License. You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* https://opensource.org/licenses/MIT
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
/* eslint-disable require-jsdoc */
|
|
25
|
+
const base_1 = require("../../base");
|
|
26
|
+
const errors_1 = require("@oclif/core/lib/errors");
|
|
27
|
+
const prettyjson_1 = require("prettyjson");
|
|
28
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
29
|
+
const moment_1 = __importDefault(require("moment"));
|
|
30
|
+
class DescribeCommand extends base_1.BaseCommand {
|
|
31
|
+
async run() {
|
|
32
|
+
const { args, flags } = await this.parse(DescribeCommand);
|
|
33
|
+
const { endpoint, insecure } = flags;
|
|
34
|
+
const api = new sdk_1.default.ACL({ endpoint, insecure });
|
|
35
|
+
try {
|
|
36
|
+
const acl = await api.getACL(args.ref);
|
|
37
|
+
const jsonObj = {
|
|
38
|
+
Ref: acl.ref,
|
|
39
|
+
APIVersion: acl.apiVersion,
|
|
40
|
+
Name: acl.name,
|
|
41
|
+
Deny: acl.deny.join(","),
|
|
42
|
+
Allow: acl.allow.join(","),
|
|
43
|
+
Extended: acl.extended,
|
|
44
|
+
Created: (0, moment_1.default)(new Date(acl.createdAt * 1000)).toISOString(),
|
|
45
|
+
Updated: (0, moment_1.default)(new Date(acl.updatedAt * 1000)).toISOString()
|
|
46
|
+
};
|
|
47
|
+
this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
throw new errors_1.CLIError(e.message);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.default = DescribeCommand;
|
|
55
|
+
DescribeCommand.description = "shows details of an ACL";
|
|
56
|
+
DescribeCommand.args = [
|
|
57
|
+
{
|
|
58
|
+
name: "ref",
|
|
59
|
+
required: false,
|
|
60
|
+
description: "reference to the ACL"
|
|
61
|
+
}
|
|
62
|
+
];
|
|
@@ -5,6 +5,7 @@ export default class GetCommand extends BaseCommand {
|
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
7
|
size: import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
8
|
+
extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
9
|
};
|
|
9
10
|
static args: {
|
|
10
11
|
name: string;
|
package/dist/commands/acl/get.js
CHANGED
|
@@ -42,12 +42,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
* limitations under the License.
|
|
43
43
|
*/
|
|
44
44
|
/* eslint-disable require-jsdoc */
|
|
45
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
45
46
|
const core_1 = require("@oclif/core");
|
|
46
47
|
const base_1 = require("../../base");
|
|
47
48
|
const utils_1 = require("../../utils");
|
|
48
49
|
const common_1 = require("@routr/common");
|
|
49
50
|
const errors_1 = require("@oclif/core/lib/errors");
|
|
50
|
-
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
51
51
|
class GetCommand extends base_1.BaseCommand {
|
|
52
52
|
async run() {
|
|
53
53
|
const { args, flags } = await this.parse(GetCommand);
|
|
@@ -68,25 +68,6 @@ class GetCommand extends base_1.BaseCommand {
|
|
|
68
68
|
allow: {
|
|
69
69
|
header: "Allow CIDR Networks",
|
|
70
70
|
get: (row) => row.allow.join(", ")
|
|
71
|
-
},
|
|
72
|
-
createdAt: {
|
|
73
|
-
header: "Created",
|
|
74
|
-
get: (row) => new Date(row.createdAt * 1000),
|
|
75
|
-
extended: true
|
|
76
|
-
},
|
|
77
|
-
updatedAt: {
|
|
78
|
-
header: "Updated",
|
|
79
|
-
get: (row) => new Date(row.updatedAt * 1000),
|
|
80
|
-
extended: true
|
|
81
|
-
},
|
|
82
|
-
extended: {
|
|
83
|
-
header: "Extended",
|
|
84
|
-
get: (row) => row.extended || {},
|
|
85
|
-
extended: true
|
|
86
|
-
},
|
|
87
|
-
apiVersion: {
|
|
88
|
-
header: "API",
|
|
89
|
-
extended: true
|
|
90
71
|
}
|
|
91
72
|
}, {
|
|
92
73
|
"no-header": !showHeader,
|
|
@@ -124,6 +105,10 @@ GetCommand.flags = {
|
|
|
124
105
|
char: "s",
|
|
125
106
|
description: "the number of items to return",
|
|
126
107
|
default: 50
|
|
108
|
+
}),
|
|
109
|
+
extended: core_1.Flags.boolean({
|
|
110
|
+
char: "x",
|
|
111
|
+
description: "extended output format"
|
|
127
112
|
})
|
|
128
113
|
};
|
|
129
114
|
GetCommand.args = [
|
|
@@ -36,55 +36,55 @@ class UpdateCommand extends base_1.BaseCommand {
|
|
|
36
36
|
const { args, flags } = await this.parse(UpdateCommand);
|
|
37
37
|
const { endpoint, insecure } = flags;
|
|
38
38
|
const api = new sdk_1.default.ACL({ endpoint, insecure });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
39
|
+
try {
|
|
40
|
+
const aclFromDB = await api.getACL(args.ref);
|
|
41
|
+
this.log("This utility will help you update an existing ACL.");
|
|
42
|
+
this.log("Press ^C at any time to quit.");
|
|
43
|
+
const answers = await inquirer_1.default.prompt([
|
|
44
|
+
{
|
|
45
|
+
name: "name",
|
|
46
|
+
message: "Friendly Name",
|
|
47
|
+
type: "input",
|
|
48
|
+
default: aclFromDB.name,
|
|
49
|
+
validate: validators_1.nameValidator
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "deny",
|
|
53
|
+
message: "Deny CIDR Networks",
|
|
54
|
+
type: "input",
|
|
55
|
+
default: aclFromDB.deny.join(","),
|
|
56
|
+
validate: validators_1.aclRuleValidator
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "allow",
|
|
60
|
+
message: "Allow CIDR Networks",
|
|
61
|
+
type: "input",
|
|
62
|
+
default: aclFromDB.allow.join(","),
|
|
63
|
+
validate: validators_1.aclRuleValidator
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "confirm",
|
|
67
|
+
message: "Ready?",
|
|
68
|
+
type: "confirm"
|
|
69
|
+
}
|
|
70
|
+
]);
|
|
71
|
+
answers.ref = args.ref;
|
|
72
|
+
// Re-assign allow and deny rules as arrays
|
|
73
|
+
answers.allow = (0, utils_1.stringToACL)(answers.allow);
|
|
74
|
+
answers.deny = (0, utils_1.stringToACL)(answers.deny);
|
|
75
|
+
if (!answers.confirm) {
|
|
76
|
+
this.warn("Aborted");
|
|
68
77
|
}
|
|
69
|
-
|
|
70
|
-
answers.ref = args.ref;
|
|
71
|
-
// Re-assign allow and deny rules as arrays
|
|
72
|
-
answers.allow = (0, utils_1.stringToACL)(answers.allow);
|
|
73
|
-
answers.deny = (0, utils_1.stringToACL)(answers.deny);
|
|
74
|
-
if (!answers.confirm) {
|
|
75
|
-
this.warn("Aborted");
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
try {
|
|
78
|
+
else {
|
|
79
79
|
core_1.CliUx.ux.action.start(`Updating ACL ${answers.name}`);
|
|
80
80
|
const acl = await api.updateACL(answers);
|
|
81
81
|
await core_1.CliUx.ux.wait(1000);
|
|
82
82
|
core_1.CliUx.ux.action.stop(acl.ref);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
core_1.CliUx.ux.action.stop();
|
|
87
|
+
throw new errors_1.CLIError(e.message);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -62,110 +62,110 @@ class CreateAgentCommand extends base_1.BaseCommand {
|
|
|
62
62
|
async run() {
|
|
63
63
|
const { flags } = await this.parse(CreateAgentCommand);
|
|
64
64
|
const { endpoint, insecure } = flags;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
65
|
+
try {
|
|
66
|
+
// TODO: Fix hardcoded pageSize
|
|
67
|
+
const domains = await new sdk_1.default.Domains({ endpoint, insecure }).listDomains({
|
|
68
|
+
pageSize: 25,
|
|
69
|
+
pageToken: ""
|
|
70
|
+
});
|
|
71
|
+
// TODO: Fix hardcoded pageSize
|
|
72
|
+
const credentials = await new sdk_1.default.Credentials({
|
|
73
|
+
endpoint,
|
|
74
|
+
insecure
|
|
75
|
+
}).listCredentials({
|
|
76
|
+
pageSize: 25,
|
|
77
|
+
pageToken: ""
|
|
78
|
+
});
|
|
79
|
+
const domainsList = domains.items.map((domain) => {
|
|
80
|
+
return {
|
|
81
|
+
name: domain.domainUri,
|
|
82
|
+
description: domain.name,
|
|
83
|
+
value: domain.ref
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
const credentialsList = credentials.items.map((credential) => {
|
|
87
|
+
return { name: credential.name, value: credential.ref };
|
|
88
|
+
});
|
|
89
|
+
const searcher = new fuzzy_search_1.default(domainsList, ["name", "value", "description"], {
|
|
90
|
+
caseSensitive: false
|
|
91
|
+
});
|
|
92
|
+
this.log("This utility will help you create a new Agent.");
|
|
93
|
+
this.log("Press ^C at any time to quit.");
|
|
94
|
+
const answers = await inquirer_1.default.prompt([
|
|
95
|
+
{
|
|
96
|
+
name: "name",
|
|
97
|
+
message: "Friendly Name",
|
|
98
|
+
type: "input",
|
|
99
|
+
validate: validators_1.nameValidator
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: "autocomplete",
|
|
103
|
+
name: "domainRef",
|
|
104
|
+
message: "Select a Domain",
|
|
105
|
+
source: (_, input) => searcher.search(input),
|
|
106
|
+
when: () => domains.items.length > 0
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "username",
|
|
110
|
+
message: "Username",
|
|
111
|
+
type: "input",
|
|
112
|
+
validate: validators_1.usernameValidator
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "credentialsRef",
|
|
116
|
+
message: "Credentials Name",
|
|
117
|
+
type: "list",
|
|
118
|
+
choices: [{ name: "None", value: undefined }, ...credentialsList]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "privacy",
|
|
122
|
+
message: "Privacy",
|
|
123
|
+
type: "list",
|
|
124
|
+
choices: [
|
|
125
|
+
{
|
|
126
|
+
name: "None",
|
|
127
|
+
value: common_1.CommonTypes.Privacy.NONE
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "Private",
|
|
131
|
+
value: common_1.CommonTypes.Privacy.PRIVATE
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
default: common_1.CommonTypes.Privacy.NONE
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "enabled",
|
|
138
|
+
message: "Enabled?",
|
|
139
|
+
type: "confirm",
|
|
140
|
+
default: true
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "confirm",
|
|
144
|
+
message: "Ready?",
|
|
145
|
+
type: "confirm"
|
|
146
|
+
}
|
|
147
|
+
]);
|
|
148
|
+
// Re-write privacy to enum
|
|
149
|
+
answers.privacy =
|
|
150
|
+
common_1.CommonTypes.Privacy[answers.privacy.toUpperCase()];
|
|
151
|
+
if (!answers.confirm) {
|
|
152
|
+
this.warn("Aborted");
|
|
145
153
|
}
|
|
146
|
-
|
|
147
|
-
// Re-write privacy to enum
|
|
148
|
-
answers.privacy =
|
|
149
|
-
common_1.CommonTypes.Privacy[answers.privacy.toUpperCase()];
|
|
150
|
-
if (!answers.confirm) {
|
|
151
|
-
this.warn("Aborted");
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
try {
|
|
154
|
+
else {
|
|
155
155
|
core_1.CliUx.ux.action.start(`Creating Agent ${answers.name}`);
|
|
156
156
|
const api = new sdk_1.default.Agents({ endpoint, insecure });
|
|
157
157
|
const agent = await api.createAgent(answers);
|
|
158
158
|
await core_1.CliUx.ux.wait(1000);
|
|
159
159
|
core_1.CliUx.ux.action.stop(agent.ref);
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
core_1.CliUx.ux.action.stop();
|
|
164
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
165
|
+
throw new errors_1.CLIError("This Agent already exist");
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
throw new errors_1.CLIError(e.message);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
8
|
+
* http://github.com/fonoster
|
|
9
|
+
*
|
|
10
|
+
* This file is part of Routr.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the MIT License (the "License");
|
|
13
|
+
* you may not use this file except in compliance with
|
|
14
|
+
* the License. You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* https://opensource.org/licenses/MIT
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
/* eslint-disable require-jsdoc */
|
|
25
|
+
const base_1 = require("../../base");
|
|
26
|
+
const errors_1 = require("@oclif/core/lib/errors");
|
|
27
|
+
const prettyjson_1 = require("prettyjson");
|
|
28
|
+
const utils_1 = require("../../utils");
|
|
29
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
30
|
+
const moment_1 = __importDefault(require("moment"));
|
|
31
|
+
class DescribeCommand extends base_1.BaseCommand {
|
|
32
|
+
async run() {
|
|
33
|
+
var _a;
|
|
34
|
+
const { args, flags } = await this.parse(DescribeCommand);
|
|
35
|
+
const { endpoint, insecure } = flags;
|
|
36
|
+
const api = new sdk_1.default.Agents({ endpoint, insecure });
|
|
37
|
+
try {
|
|
38
|
+
const agent = await api.getAgent(args.ref);
|
|
39
|
+
const jsonObj = {
|
|
40
|
+
Ref: agent.ref,
|
|
41
|
+
APIVersion: agent.apiVersion,
|
|
42
|
+
Name: agent.name,
|
|
43
|
+
Username: agent.username,
|
|
44
|
+
Domain: ((_a = agent.domain) === null || _a === void 0 ? void 0 : _a.domainUri) || "None",
|
|
45
|
+
Privacy: (0, utils_1.capitalize)(agent.privacy),
|
|
46
|
+
Credentials: agent.credentials
|
|
47
|
+
? {
|
|
48
|
+
Ref: agent.credentials.ref,
|
|
49
|
+
Username: agent.credentials.username
|
|
50
|
+
}
|
|
51
|
+
: "None",
|
|
52
|
+
Enabled: agent.enabled ? "Yes" : "No",
|
|
53
|
+
Extended: agent.extended,
|
|
54
|
+
Created: (0, moment_1.default)(new Date(agent.createdAt * 1000)).toISOString(),
|
|
55
|
+
Updated: (0, moment_1.default)(new Date(agent.updatedAt * 1000)).toISOString()
|
|
56
|
+
};
|
|
57
|
+
this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
throw new errors_1.CLIError(e.message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = DescribeCommand;
|
|
65
|
+
DescribeCommand.description = "shows details of an Agent";
|
|
66
|
+
DescribeCommand.args = [
|
|
67
|
+
{
|
|
68
|
+
name: "ref",
|
|
69
|
+
required: false,
|
|
70
|
+
description: "reference to the Agent"
|
|
71
|
+
}
|
|
72
|
+
];
|
|
@@ -5,6 +5,7 @@ export default class GetAgentsCommand extends BaseCommand {
|
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
7
|
size: import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
8
|
+
extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
9
|
};
|
|
9
10
|
static args: {
|
|
10
11
|
name: string;
|