@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,124 +59,130 @@ class CreateTrunkCommand extends base_1.BaseCommand {
|
|
|
59
59
|
async run() {
|
|
60
60
|
const { flags } = await this.parse(CreateTrunkCommand);
|
|
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
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
62
|
+
try {
|
|
63
|
+
// TODO: Add support for pagination
|
|
64
|
+
const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
|
|
65
|
+
pageSize: 25,
|
|
66
|
+
pageToken: ""
|
|
67
|
+
});
|
|
68
|
+
const aclChoices = acls.items.map((acl) => {
|
|
69
|
+
return {
|
|
70
|
+
name: acl.name,
|
|
71
|
+
value: acl.ref
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
const credentials = await new sdk_1.default.Credentials({
|
|
75
|
+
endpoint,
|
|
76
|
+
insecure
|
|
77
|
+
}).listCredentials({
|
|
78
|
+
pageSize: 25,
|
|
79
|
+
pageToken: ""
|
|
80
|
+
});
|
|
81
|
+
const credentialsChoice = credentials.items.map((acl) => {
|
|
82
|
+
return {
|
|
83
|
+
name: acl.name,
|
|
84
|
+
value: acl.ref
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
this.log("This utility will help you create a new Trunk.");
|
|
88
|
+
this.log("Press ^C at any time to quit.");
|
|
89
|
+
const group1 = await inquirer_1.default.prompt([
|
|
90
|
+
{
|
|
91
|
+
name: "name",
|
|
92
|
+
message: "Friendly Name",
|
|
93
|
+
type: "input",
|
|
94
|
+
validate: validators_1.nameValidator
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "inboundUri",
|
|
98
|
+
message: "Inbound SIP URI",
|
|
99
|
+
type: "input",
|
|
100
|
+
validate: validators_1.inboundUriValidator
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "accessControlListRef",
|
|
104
|
+
message: "IP Access Control List",
|
|
105
|
+
type: "list",
|
|
106
|
+
choices: [{ name: "None", value: undefined }, ...aclChoices]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "inboundCredentialsRef",
|
|
110
|
+
message: "Inbound Credentials",
|
|
111
|
+
type: "list",
|
|
112
|
+
choices: [{ name: "None", value: undefined }, ...credentialsChoice]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "outboundCredentialsRef",
|
|
116
|
+
message: "Outbound Credentials",
|
|
117
|
+
type: "list",
|
|
118
|
+
choices: [{ name: "None", value: undefined }, ...credentialsChoice]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "sendRegister",
|
|
122
|
+
message: "Send Register?",
|
|
123
|
+
type: "confirm",
|
|
124
|
+
default: false
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "addOutboundUri",
|
|
128
|
+
message: "Add an Outbound SIP URI?",
|
|
129
|
+
type: "confirm",
|
|
130
|
+
default: false
|
|
131
|
+
}
|
|
132
|
+
]);
|
|
133
|
+
const group2Questions = [
|
|
134
|
+
{
|
|
135
|
+
name: "host",
|
|
136
|
+
message: "Host",
|
|
137
|
+
type: "input",
|
|
138
|
+
validate: validators_1.hostValidator
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "port",
|
|
142
|
+
message: "Post",
|
|
143
|
+
type: "input",
|
|
144
|
+
default: "5060",
|
|
145
|
+
validate: validators_1.portValidator
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "transport",
|
|
149
|
+
message: "Transport",
|
|
150
|
+
type: "list",
|
|
151
|
+
choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
|
|
152
|
+
default: common_1.CommonTypes.Transport.UDP
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "user",
|
|
156
|
+
message: "User Part",
|
|
157
|
+
type: "input",
|
|
158
|
+
validate: validators_1.optionalUsernameValidator
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "priority",
|
|
162
|
+
message: "Priority",
|
|
163
|
+
type: "input",
|
|
164
|
+
default: "10",
|
|
165
|
+
validate: validators_1.priorityValidator
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "weight",
|
|
169
|
+
message: "Weight",
|
|
170
|
+
type: "input",
|
|
171
|
+
default: "10",
|
|
172
|
+
validate: validators_1.weightValidator
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "addOutboundUri",
|
|
176
|
+
message: "Add another Outbound SIP URI?",
|
|
177
|
+
type: "confirm",
|
|
178
|
+
default: false
|
|
179
|
+
}
|
|
180
|
+
];
|
|
181
|
+
let addOutboundUri = group1.addOutboundUri;
|
|
182
|
+
const uris = [];
|
|
183
|
+
// eslint-disable-next-line no-loops/no-loops
|
|
184
|
+
while (addOutboundUri) {
|
|
185
|
+
const group2 = await inquirer_1.default.prompt(group2Questions);
|
|
180
186
|
uris.push({
|
|
181
187
|
host: group2.host,
|
|
182
188
|
port: group2.port,
|
|
@@ -186,21 +192,19 @@ class CreateTrunkCommand extends base_1.BaseCommand {
|
|
|
186
192
|
weight: group2.weight,
|
|
187
193
|
enabled: true
|
|
188
194
|
});
|
|
195
|
+
addOutboundUri = group2.addOutboundUri;
|
|
189
196
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
const group3 = await inquirer_1.default.prompt([
|
|
198
|
+
{
|
|
199
|
+
name: "confirm",
|
|
200
|
+
message: "Ready?",
|
|
201
|
+
type: "confirm"
|
|
202
|
+
}
|
|
203
|
+
]);
|
|
204
|
+
if (!group3.confirm) {
|
|
205
|
+
this.warn("Aborted");
|
|
197
206
|
}
|
|
198
|
-
|
|
199
|
-
if (!group3.confirm) {
|
|
200
|
-
this.warn("Aborted");
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
try {
|
|
207
|
+
else {
|
|
204
208
|
core_1.CliUx.ux.action.start(`Creating Trunk ${group1.name}`);
|
|
205
209
|
const api = new sdk_1.default.Trunks({ endpoint, insecure });
|
|
206
210
|
const trunk = await api.createTrunk({
|
|
@@ -210,14 +214,14 @@ class CreateTrunkCommand extends base_1.BaseCommand {
|
|
|
210
214
|
await core_1.CliUx.ux.wait(1000);
|
|
211
215
|
core_1.CliUx.ux.action.stop(trunk.ref);
|
|
212
216
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
}
|
|
218
|
+
catch (e) {
|
|
219
|
+
core_1.CliUx.ux.action.stop();
|
|
220
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
221
|
+
throw new errors_1.CLIError("This Trunk already exist");
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
throw new errors_1.CLIError(e.message);
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
227
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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.Trunks({ endpoint, insecure });
|
|
35
|
+
try {
|
|
36
|
+
const trunk = await api.getTrunk(args.ref);
|
|
37
|
+
const jsonObj = {
|
|
38
|
+
Ref: trunk.ref,
|
|
39
|
+
APIVersion: trunk.apiVersion,
|
|
40
|
+
Name: trunk.name,
|
|
41
|
+
"Inbound URI": trunk.inboundUri,
|
|
42
|
+
"Access Control List": trunk.accessControlList
|
|
43
|
+
? {
|
|
44
|
+
Ref: trunk.accessControlList.ref,
|
|
45
|
+
Name: trunk.accessControlList.name,
|
|
46
|
+
Deny: trunk.accessControlList.deny.join(","),
|
|
47
|
+
Allow: trunk.accessControlList.allow.join(",")
|
|
48
|
+
}
|
|
49
|
+
: "None",
|
|
50
|
+
"Inbound Credentials": trunk.inboundCredentials
|
|
51
|
+
? {
|
|
52
|
+
Ref: trunk.inboundCredentials.ref,
|
|
53
|
+
Username: trunk.inboundCredentials.username
|
|
54
|
+
}
|
|
55
|
+
: "None",
|
|
56
|
+
"Outbound Credentials": trunk.outboundCredentials
|
|
57
|
+
? {
|
|
58
|
+
Ref: trunk.outboundCredentials.ref,
|
|
59
|
+
Username: trunk.outboundCredentials.username
|
|
60
|
+
}
|
|
61
|
+
: "None",
|
|
62
|
+
"Outbound URIs": trunk.uris
|
|
63
|
+
.map((uri) => `${uri.host}:${uri.port} [transport=${uri.transport};weight=${uri.weight};priority=${uri.priority}]`)
|
|
64
|
+
.join(",") || "None",
|
|
65
|
+
"Send Register": trunk.sendRegister,
|
|
66
|
+
Extended: trunk.extended,
|
|
67
|
+
Created: (0, moment_1.default)(new Date(trunk.createdAt * 1000)).toISOString(),
|
|
68
|
+
Updated: (0, moment_1.default)(new Date(trunk.updatedAt * 1000)).toISOString()
|
|
69
|
+
};
|
|
70
|
+
this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
throw new errors_1.CLIError(e.message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = DescribeCommand;
|
|
78
|
+
DescribeCommand.description = "shows details for a Trunk";
|
|
79
|
+
DescribeCommand.args = [
|
|
80
|
+
{
|
|
81
|
+
name: "ref",
|
|
82
|
+
required: false,
|
|
83
|
+
description: "reference to the Trunk"
|
|
84
|
+
}
|
|
85
|
+
];
|
|
@@ -5,6 +5,7 @@ export default class GetTrunksCommand 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;
|
|
@@ -64,39 +64,8 @@ class GetTrunksCommand extends base_1.BaseCommand {
|
|
|
64
64
|
inboundUri: {
|
|
65
65
|
header: "Inbound SIP URI"
|
|
66
66
|
},
|
|
67
|
-
|
|
68
|
-
header: "
|
|
69
|
-
get: (row) => { var _a; return ((_a = row.accessControlList) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
|
|
70
|
-
extended: true
|
|
71
|
-
},
|
|
72
|
-
inboundCredentialsRef: {
|
|
73
|
-
header: "Inbound Credentials Name",
|
|
74
|
-
get: (row) => { var _a; return ((_a = row.inboundCredentials) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
|
|
75
|
-
extended: true
|
|
76
|
-
},
|
|
77
|
-
outboundCredentialsRef: {
|
|
78
|
-
header: "Outbound Credentials Name",
|
|
79
|
-
get: (row) => { var _a; return ((_a = row.outboundCredentials) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
|
|
80
|
-
extended: true
|
|
81
|
-
},
|
|
82
|
-
createdAt: {
|
|
83
|
-
header: "Created",
|
|
84
|
-
get: (row) => new Date(row.createdAt * 1000),
|
|
85
|
-
extended: true
|
|
86
|
-
},
|
|
87
|
-
updatedAt: {
|
|
88
|
-
header: "Updated",
|
|
89
|
-
get: (row) => new Date(row.updatedAt * 1000),
|
|
90
|
-
extended: true
|
|
91
|
-
},
|
|
92
|
-
extended: {
|
|
93
|
-
header: "Extended",
|
|
94
|
-
get: (row) => row.extended || {},
|
|
95
|
-
extended: true
|
|
96
|
-
},
|
|
97
|
-
apiVersion: {
|
|
98
|
-
header: "API",
|
|
99
|
-
extended: true
|
|
67
|
+
sendRegister: {
|
|
68
|
+
header: "Send Register"
|
|
100
69
|
}
|
|
101
70
|
}, {
|
|
102
71
|
"no-header": !showHeader,
|
|
@@ -134,6 +103,10 @@ GetTrunksCommand.flags = {
|
|
|
134
103
|
char: "s",
|
|
135
104
|
description: "the number of items to return",
|
|
136
105
|
default: 50
|
|
106
|
+
}),
|
|
107
|
+
extended: core_1.Flags.boolean({
|
|
108
|
+
char: "x",
|
|
109
|
+
description: "extended output format"
|
|
137
110
|
})
|
|
138
111
|
};
|
|
139
112
|
GetTrunksCommand.args = [
|