@routr/ctl 2.0.8-alpha.22 → 2.0.8-alpha.24
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 +1 -1
- package/dist/commands/acl/create.js +43 -43
- package/dist/commands/acl/get.js +1 -1
- package/dist/commands/acl/update.js +43 -43
- package/dist/commands/agents/create.js +97 -97
- package/dist/commands/agents/update.js +88 -88
- package/dist/commands/credentials/update.js +39 -39
- package/dist/commands/domains/create.js +105 -105
- package/dist/commands/domains/update.js +99 -99
- package/dist/commands/numbers/create.js +88 -88
- package/dist/commands/numbers/update.js +69 -69
- package/dist/commands/peers/create.js +100 -97
- package/dist/commands/peers/update.js +97 -94
- package/dist/commands/trunks/create.js +148 -148
- package/dist/commands/trunks/update.js +151 -151
- package/dist/delete.js +8 -3
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
|
@@ -37,106 +37,109 @@ class UpdatePeerCommand extends base_1.BaseCommand {
|
|
|
37
37
|
const { args, flags } = await this.parse(UpdatePeerCommand);
|
|
38
38
|
const { endpoint, insecure } = flags;
|
|
39
39
|
const api = new sdk_1.default.Peers({ endpoint, insecure });
|
|
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
|
-
|
|
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
|
-
|
|
40
|
+
try {
|
|
41
|
+
const peerFromDB = await api.getPeer(args.ref);
|
|
42
|
+
// TODO: Fix hardcoded pageSize
|
|
43
|
+
const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
|
|
44
|
+
pageSize: 25,
|
|
45
|
+
pageToken: ""
|
|
46
|
+
});
|
|
47
|
+
// TODO: Fix hardcoded pageSize
|
|
48
|
+
const credentials = await new sdk_1.default.Credentials({
|
|
49
|
+
endpoint,
|
|
50
|
+
insecure
|
|
51
|
+
}).listCredentials({
|
|
52
|
+
pageSize: 25,
|
|
53
|
+
pageToken: ""
|
|
54
|
+
});
|
|
55
|
+
const aclList = ((_a = acls.items) === null || _a === void 0 ? void 0 : _a.map((acl) => {
|
|
56
|
+
return { name: acl.name, value: acl.ref };
|
|
57
|
+
})) || [];
|
|
58
|
+
const credentialsList = ((_b = credentials.items) === null || _b === void 0 ? void 0 : _b.map((credential) => {
|
|
59
|
+
return { name: credential.name, value: credential.ref };
|
|
60
|
+
})) || [];
|
|
61
|
+
this.log("This utility will help you update an existing Peer.");
|
|
62
|
+
this.log("Press ^C at any time to quit.");
|
|
63
|
+
const answers = await inquirer_1.default.prompt([
|
|
64
|
+
{
|
|
65
|
+
name: "name",
|
|
66
|
+
message: "Friendly Name",
|
|
67
|
+
type: "input",
|
|
68
|
+
default: peerFromDB.name,
|
|
69
|
+
validate: validators_1.nameValidator
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "aor",
|
|
73
|
+
message: "Adress of Record",
|
|
74
|
+
type: "input",
|
|
75
|
+
default: peerFromDB.aor,
|
|
76
|
+
validate: validators_1.aorValidator
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "contactAddr",
|
|
80
|
+
message: "Contact Address",
|
|
81
|
+
type: "input",
|
|
82
|
+
default: peerFromDB.contactAddr || undefined,
|
|
83
|
+
validate: validators_1.contactAddrValidator
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "accessControlListRef",
|
|
87
|
+
message: "IP Access Control List",
|
|
88
|
+
choices: [{ name: "None", value: undefined }, ...aclList],
|
|
89
|
+
type: "list",
|
|
90
|
+
default: peerFromDB.accessControlListRef
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "credentialsRef",
|
|
94
|
+
message: "Credentials Name",
|
|
95
|
+
choices: [{ name: "None", value: undefined }, ...credentialsList],
|
|
96
|
+
type: "list",
|
|
97
|
+
default: peerFromDB.credentialsRef
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "withSessionAffinity",
|
|
101
|
+
message: "Enable Session Affinity?",
|
|
102
|
+
type: "confirm",
|
|
103
|
+
default: peerFromDB.withSessionAffinity,
|
|
104
|
+
when: (answers) => answers.aor.startsWith("backend:")
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "balancingAlgorithm",
|
|
108
|
+
message: "Balancing Algorithm",
|
|
109
|
+
choices: [
|
|
110
|
+
{
|
|
111
|
+
name: "Round Robin",
|
|
112
|
+
value: common_1.CommonTypes.LoadBalancingAlgorithm.ROUND_ROBIN
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "Least Sessions",
|
|
116
|
+
value: common_1.CommonTypes.LoadBalancingAlgorithm.LEAST_SESSIONS
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
type: "list",
|
|
120
|
+
default: peerFromDB.balancingAlgorithm,
|
|
121
|
+
when: (answers) => answers.aor.startsWith("backend:")
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "confirm",
|
|
125
|
+
message: "Ready?",
|
|
126
|
+
type: "confirm"
|
|
127
|
+
}
|
|
128
|
+
]);
|
|
129
|
+
answers.ref = args.ref;
|
|
130
|
+
if (!answers.confirm) {
|
|
131
|
+
this.warn("Aborted");
|
|
123
132
|
}
|
|
124
|
-
|
|
125
|
-
answers.ref = args.ref;
|
|
126
|
-
if (!answers.confirm) {
|
|
127
|
-
this.warn("Aborted");
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
try {
|
|
133
|
+
else {
|
|
131
134
|
core_1.CliUx.ux.action.start(`Updating Peer ${answers.name}`);
|
|
132
135
|
const acl = await api.updatePeer(answers);
|
|
133
136
|
await core_1.CliUx.ux.wait(1000);
|
|
134
137
|
core_1.CliUx.ux.action.stop(acl.ref);
|
|
135
138
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
core_1.CliUx.ux.action.stop();
|
|
142
|
+
throw new errors_1.CLIError(e.message);
|
|
140
143
|
}
|
|
141
144
|
}
|
|
142
145
|
}
|
|
@@ -59,148 +59,148 @@ 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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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: "addOutboundUri",
|
|
122
|
+
message: "Add an Outbound SIP URI?",
|
|
123
|
+
type: "confirm",
|
|
124
|
+
default: false
|
|
125
|
+
}
|
|
126
|
+
]);
|
|
127
|
+
const group2Questions = [
|
|
128
|
+
{
|
|
129
|
+
name: "host",
|
|
130
|
+
message: "Host",
|
|
131
|
+
type: "input",
|
|
132
|
+
validate: validators_1.hostValidator
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "port",
|
|
136
|
+
message: "Post",
|
|
137
|
+
type: "input",
|
|
138
|
+
default: "5060",
|
|
139
|
+
validate: validators_1.portValidator
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "transport",
|
|
143
|
+
message: "Transport",
|
|
144
|
+
type: "list",
|
|
145
|
+
choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
|
|
146
|
+
default: common_1.CommonTypes.Transport.UDP
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "user",
|
|
150
|
+
message: "User Part",
|
|
151
|
+
type: "input",
|
|
152
|
+
validate: validators_1.optionalUsernameValidator
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "priority",
|
|
156
|
+
message: "Priority",
|
|
157
|
+
type: "input",
|
|
158
|
+
default: "10",
|
|
159
|
+
validate: validators_1.priorityValidator
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "weight",
|
|
163
|
+
message: "Weight",
|
|
164
|
+
type: "input",
|
|
165
|
+
default: "10",
|
|
166
|
+
validate: validators_1.weightValidator
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "addOutboundUri",
|
|
170
|
+
message: "Add another Outbound SIP URI?",
|
|
171
|
+
type: "confirm",
|
|
172
|
+
default: false
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
let addOutboundUri = group1.addOutboundUri;
|
|
176
|
+
const uris = [];
|
|
177
|
+
// eslint-disable-next-line no-loops/no-loops
|
|
178
|
+
while (addOutboundUri) {
|
|
179
|
+
const group2 = await inquirer_1.default.prompt(group2Questions);
|
|
180
|
+
if (group2.numberRef) {
|
|
181
|
+
uris.push({
|
|
182
|
+
host: group2.host,
|
|
183
|
+
port: group2.port,
|
|
184
|
+
transport: group2.transport,
|
|
185
|
+
user: group2.user,
|
|
186
|
+
priority: group2.priority,
|
|
187
|
+
weight: group2.weight,
|
|
188
|
+
enabled: true
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
addOutboundUri = group2.addOutboundUri;
|
|
189
192
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
const group3 = await inquirer_1.default.prompt([
|
|
194
|
+
{
|
|
195
|
+
name: "confirm",
|
|
196
|
+
message: "Ready?",
|
|
197
|
+
type: "confirm"
|
|
198
|
+
}
|
|
199
|
+
]);
|
|
200
|
+
if (!group3.confirm) {
|
|
201
|
+
this.warn("Aborted");
|
|
197
202
|
}
|
|
198
|
-
|
|
199
|
-
if (!group3.confirm) {
|
|
200
|
-
this.warn("Aborted");
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
try {
|
|
203
|
+
else {
|
|
204
204
|
core_1.CliUx.ux.action.start(`Creating Trunk ${group1.name}`);
|
|
205
205
|
const api = new sdk_1.default.Trunks({ endpoint, insecure });
|
|
206
206
|
const trunk = await api.createTrunk({
|
|
@@ -210,14 +210,14 @@ class CreateTrunkCommand extends base_1.BaseCommand {
|
|
|
210
210
|
await core_1.CliUx.ux.wait(1000);
|
|
211
211
|
core_1.CliUx.ux.action.stop(trunk.ref);
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
core_1.CliUx.ux.action.stop();
|
|
216
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
217
|
+
throw new errors_1.CLIError("This Trunk already exist");
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
throw new errors_1.CLIError(e.message);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|