@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
|
@@ -61,103 +61,103 @@ class CreateNumberCommand extends base_1.BaseCommand {
|
|
|
61
61
|
async run() {
|
|
62
62
|
const { flags } = await this.parse(CreateNumberCommand);
|
|
63
63
|
const { endpoint, insecure } = flags;
|
|
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
|
-
|
|
64
|
+
try {
|
|
65
|
+
const searcher = new fuzzy_search_1.default(countries_1.countries, ["name"], {
|
|
66
|
+
caseSensitive: false
|
|
67
|
+
});
|
|
68
|
+
const trunks = await new sdk_1.default.Trunks({ endpoint, insecure }).listTrunks({
|
|
69
|
+
pageSize: 25,
|
|
70
|
+
pageToken: ""
|
|
71
|
+
});
|
|
72
|
+
const trunksChoices = trunks.items.map((trunk) => {
|
|
73
|
+
return {
|
|
74
|
+
name: trunk.name,
|
|
75
|
+
value: trunk.ref
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
this.log("This utility will help you create a new Number.");
|
|
79
|
+
this.log("Press ^C at any time to quit.");
|
|
80
|
+
const answers = await inquirer_1.default.prompt([
|
|
81
|
+
{
|
|
82
|
+
name: "name",
|
|
83
|
+
message: "Friendly Name",
|
|
84
|
+
type: "input",
|
|
85
|
+
validate: validators_1.nameValidator
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "telUrl",
|
|
89
|
+
message: "Telephony URL",
|
|
90
|
+
type: "input",
|
|
91
|
+
validate: validators_1.telUrlValidator
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "aorLink",
|
|
95
|
+
message: "AOR Link",
|
|
96
|
+
type: "input",
|
|
97
|
+
validate: validators_1.aorLinkValidator
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "trunkRef",
|
|
101
|
+
message: "Trunk",
|
|
102
|
+
type: "list",
|
|
103
|
+
choices: [{ name: "None", value: undefined }, ...trunksChoices]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "city",
|
|
107
|
+
message: "City",
|
|
108
|
+
type: "input",
|
|
109
|
+
validate: (input) => {
|
|
110
|
+
if (input.length === 0) {
|
|
111
|
+
return "the city is required";
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
111
114
|
}
|
|
112
|
-
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: "autocomplete",
|
|
118
|
+
name: "countryISOCode",
|
|
119
|
+
message: "Select a Country",
|
|
120
|
+
source: (_, input) => searcher.search(input)
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "sessionAffinityHeader",
|
|
124
|
+
message: "Session Affinity Header",
|
|
125
|
+
type: "input",
|
|
126
|
+
validate: validators_1.sessionAffinityHeaderValidator
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "extraHeaders",
|
|
130
|
+
message: "Extra Headers",
|
|
131
|
+
type: "input",
|
|
132
|
+
validate: validators_1.headersValidator
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "confirm",
|
|
136
|
+
message: "Ready?",
|
|
137
|
+
type: "confirm"
|
|
113
138
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: "sessionAffinityHeader",
|
|
123
|
-
message: "Session Affinity Header",
|
|
124
|
-
type: "input",
|
|
125
|
-
validate: validators_1.sessionAffinityHeaderValidator
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: "extraHeaders",
|
|
129
|
-
message: "Extra Headers",
|
|
130
|
-
type: "input",
|
|
131
|
-
validate: validators_1.headersValidator
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: "confirm",
|
|
135
|
-
message: "Ready?",
|
|
136
|
-
type: "confirm"
|
|
139
|
+
]);
|
|
140
|
+
// Re-write extraHeaders
|
|
141
|
+
answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
|
|
142
|
+
answers.country = countries_1.countries.find((country) => country.value === answers.countryISOCode).name;
|
|
143
|
+
if (!answers.confirm) {
|
|
144
|
+
this.warn("Aborted");
|
|
137
145
|
}
|
|
138
|
-
|
|
139
|
-
// Re-write extraHeaders
|
|
140
|
-
answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
|
|
141
|
-
answers.country = countries_1.countries.find((country) => country.value === answers.countryISOCode).name;
|
|
142
|
-
if (!answers.confirm) {
|
|
143
|
-
this.warn("Aborted");
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
try {
|
|
146
|
+
else {
|
|
147
147
|
core_1.CliUx.ux.action.start(`Creating Number ${answers.name}`);
|
|
148
148
|
const api = new sdk_1.default.Numbers({ endpoint, insecure });
|
|
149
149
|
const number = await api.createNumber(answers);
|
|
150
150
|
await core_1.CliUx.ux.wait(1000);
|
|
151
151
|
core_1.CliUx.ux.action.stop(number.ref);
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
core_1.CliUx.ux.action.stop();
|
|
156
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
157
|
+
throw new errors_1.CLIError("This Number already exist");
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
throw new errors_1.CLIError(e.message);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -36,81 +36,81 @@ class UpdateCommand extends base_1.BaseCommand {
|
|
|
36
36
|
var _a;
|
|
37
37
|
const { args, flags } = await this.parse(UpdateCommand);
|
|
38
38
|
const { endpoint, insecure } = flags;
|
|
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
|
-
|
|
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
|
-
|
|
39
|
+
try {
|
|
40
|
+
const api = new sdk_1.default.Numbers({ endpoint, insecure });
|
|
41
|
+
const numberFromDB = await api.getNumber(args.ref);
|
|
42
|
+
const trunks = await new sdk_1.default.Trunks({ endpoint, insecure }).listTrunks({
|
|
43
|
+
pageSize: 25,
|
|
44
|
+
pageToken: ""
|
|
45
|
+
});
|
|
46
|
+
const trunksChoices = trunks.items.map((trunk) => {
|
|
47
|
+
return {
|
|
48
|
+
name: trunk.name,
|
|
49
|
+
value: trunk.ref
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
this.log("This utility will help you update an existing Number.");
|
|
53
|
+
this.log("Press ^C at any time to quit.");
|
|
54
|
+
const answers = await inquirer_1.default.prompt([
|
|
55
|
+
{
|
|
56
|
+
name: "name",
|
|
57
|
+
message: "Friendly Name",
|
|
58
|
+
type: "input",
|
|
59
|
+
default: numberFromDB.name,
|
|
60
|
+
validate: validators_1.nameValidator
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "aorLink",
|
|
64
|
+
message: "AOR Link",
|
|
65
|
+
type: "input",
|
|
66
|
+
default: numberFromDB.aorLink || undefined,
|
|
67
|
+
validate: validators_1.aorLinkValidator
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "trunkRef",
|
|
71
|
+
message: "Trunk",
|
|
72
|
+
type: "list",
|
|
73
|
+
choices: [{ name: "None", value: undefined }, ...trunksChoices],
|
|
74
|
+
default: numberFromDB.trunkRef
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "sessionAffinityHeader",
|
|
78
|
+
message: "Session Affinity Header",
|
|
79
|
+
type: "input",
|
|
80
|
+
default: numberFromDB.sessionAffinityHeader || undefined,
|
|
81
|
+
validate: validators_1.sessionAffinityHeaderValidator
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "extraHeaders",
|
|
85
|
+
message: "Extra Headers",
|
|
86
|
+
type: "input",
|
|
87
|
+
default: ((_a = numberFromDB.extraHeaders) === null || _a === void 0 ? void 0 : _a.map((header) => {
|
|
88
|
+
return `${header.name}:${header.value}`;
|
|
89
|
+
}).join(",")) || undefined,
|
|
90
|
+
validate: validators_1.headersValidator
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "confirm",
|
|
94
|
+
message: "Ready?",
|
|
95
|
+
type: "confirm"
|
|
96
|
+
}
|
|
97
|
+
]);
|
|
98
|
+
answers.ref = args.ref;
|
|
99
|
+
// Re-write extraHeaders
|
|
100
|
+
answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
|
|
101
|
+
if (!answers.confirm) {
|
|
102
|
+
this.warn("Aborted");
|
|
95
103
|
}
|
|
96
|
-
|
|
97
|
-
answers.ref = args.ref;
|
|
98
|
-
// Re-write extraHeaders
|
|
99
|
-
answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
|
|
100
|
-
if (!answers.confirm) {
|
|
101
|
-
this.warn("Aborted");
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
try {
|
|
104
|
+
else {
|
|
105
105
|
core_1.CliUx.ux.action.start(`Updating Number ${answers.name}`);
|
|
106
106
|
const number = await api.updateNumber(answers);
|
|
107
107
|
await core_1.CliUx.ux.wait(1000);
|
|
108
108
|
core_1.CliUx.ux.action.stop(number.ref);
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
core_1.CliUx.ux.action.stop();
|
|
113
|
+
throw new errors_1.CLIError(e.message);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -60,110 +60,113 @@ class CreateCommand extends base_1.BaseCommand {
|
|
|
60
60
|
var _a, _b;
|
|
61
61
|
const { flags } = await this.parse(CreateCommand);
|
|
62
62
|
const { endpoint, insecure } = flags;
|
|
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
|
-
|
|
63
|
+
try {
|
|
64
|
+
// TODO: Fix hardcoded pageSize
|
|
65
|
+
const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
|
|
66
|
+
pageSize: 25,
|
|
67
|
+
pageToken: ""
|
|
68
|
+
});
|
|
69
|
+
// TODO: Fix hardcoded pageSize
|
|
70
|
+
const credentials = await new sdk_1.default.Credentials({
|
|
71
|
+
endpoint,
|
|
72
|
+
insecure
|
|
73
|
+
}).listCredentials({
|
|
74
|
+
pageSize: 25,
|
|
75
|
+
pageToken: ""
|
|
76
|
+
});
|
|
77
|
+
const aclList = ((_a = acls.items) === null || _a === void 0 ? void 0 : _a.map((acl) => {
|
|
78
|
+
return { name: acl.name, value: acl.ref };
|
|
79
|
+
})) || [];
|
|
80
|
+
const credentialsList = ((_b = credentials.items) === null || _b === void 0 ? void 0 : _b.map((credential) => {
|
|
81
|
+
return { name: credential.name, value: credential.ref };
|
|
82
|
+
})) || [];
|
|
83
|
+
this.log("This utility will help you create a new Peer.");
|
|
84
|
+
this.log("Press ^C at any time to quit.");
|
|
85
|
+
const answers = await inquirer_1.default.prompt([
|
|
86
|
+
{
|
|
87
|
+
name: "name",
|
|
88
|
+
message: "Friendly Name",
|
|
89
|
+
type: "input",
|
|
90
|
+
validate: validators_1.nameValidator
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "username",
|
|
94
|
+
message: "Username",
|
|
95
|
+
type: "input",
|
|
96
|
+
validate: validators_1.usernameValidator
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "aor",
|
|
100
|
+
message: "Adress of Record",
|
|
101
|
+
type: "input",
|
|
102
|
+
validate: validators_1.aorValidator
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "contactAddr",
|
|
106
|
+
message: "Contact Address",
|
|
107
|
+
type: "input",
|
|
108
|
+
validate: validators_1.contactAddrValidator
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "accessControlListRef",
|
|
112
|
+
message: "IP Access Control List",
|
|
113
|
+
choices: [{ name: "None", value: undefined }, ...aclList],
|
|
114
|
+
type: "list"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "credentialsRef",
|
|
118
|
+
message: "Credentials Name",
|
|
119
|
+
choices: [{ name: "None", value: undefined }, ...credentialsList],
|
|
120
|
+
type: "list"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "withSessionAffinity",
|
|
124
|
+
message: "Enable Session Affinity?",
|
|
125
|
+
type: "confirm",
|
|
126
|
+
default: false,
|
|
127
|
+
when: (answers) => answers.aor.startsWith("backend:")
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "balancingAlgorithm",
|
|
131
|
+
message: "Balancing Algorithm",
|
|
132
|
+
choices: [
|
|
133
|
+
{
|
|
134
|
+
name: "Round Robin",
|
|
135
|
+
value: common_1.CommonTypes.LoadBalancingAlgorithm.ROUND_ROBIN
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "Least Sessions",
|
|
139
|
+
value: common_1.CommonTypes.LoadBalancingAlgorithm.LEAST_SESSIONS
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
type: "list",
|
|
143
|
+
default: common_1.CommonTypes.LoadBalancingAlgorithm.ROUND_ROBIN,
|
|
144
|
+
when: (answers) => answers.aor.startsWith("backend:")
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "confirm",
|
|
148
|
+
message: "Ready?",
|
|
149
|
+
type: "confirm"
|
|
150
|
+
}
|
|
151
|
+
]);
|
|
152
|
+
if (!answers.confirm) {
|
|
153
|
+
this.warn("Aborted");
|
|
146
154
|
}
|
|
147
|
-
|
|
148
|
-
if (!answers.confirm) {
|
|
149
|
-
this.warn("Aborted");
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
try {
|
|
155
|
+
else {
|
|
153
156
|
core_1.CliUx.ux.action.start(`Creating Peer ${answers.name}`);
|
|
154
157
|
const api = new sdk_1.default.Peers({ endpoint, insecure });
|
|
155
158
|
const peer = await api.createPeer(answers);
|
|
156
159
|
await core_1.CliUx.ux.wait(1000);
|
|
157
160
|
core_1.CliUx.ux.action.stop(peer.ref);
|
|
158
161
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
core_1.CliUx.ux.action.stop();
|
|
165
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
166
|
+
throw new errors_1.CLIError("This Peer already exist");
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
throw new errors_1.CLIError(e.message);
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
}
|