@routr/ctl 2.0.8-alpha.21
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/LICENSE +21 -0
- package/README.md +973 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +25 -0
- package/bin/run.cmd +3 -0
- package/dist/base.d.ts +8 -0
- package/dist/base.js +42 -0
- package/dist/commands/acl/create.d.ts +6 -0
- package/dist/commands/acl/create.js +122 -0
- package/dist/commands/acl/delete.d.ts +6 -0
- package/dist/commands/acl/delete.js +40 -0
- package/dist/commands/acl/get.d.ts +19 -0
- package/dist/commands/acl/get.js +135 -0
- package/dist/commands/acl/update.d.ts +11 -0
- package/dist/commands/acl/update.js +100 -0
- package/dist/commands/agents/create.d.ts +6 -0
- package/dist/commands/agents/create.js +179 -0
- package/dist/commands/agents/delete.d.ts +6 -0
- package/dist/commands/agents/delete.js +40 -0
- package/dist/commands/agents/get.d.ts +19 -0
- package/dist/commands/agents/get.js +149 -0
- package/dist/commands/agents/update.d.ts +11 -0
- package/dist/commands/agents/update.js +150 -0
- package/dist/commands/credentials/create.d.ts +6 -0
- package/dist/commands/credentials/create.js +122 -0
- package/dist/commands/credentials/delete.d.ts +6 -0
- package/dist/commands/credentials/delete.js +40 -0
- package/dist/commands/credentials/get.d.ts +19 -0
- package/dist/commands/credentials/get.js +130 -0
- package/dist/commands/credentials/update.d.ts +11 -0
- package/dist/commands/credentials/update.js +98 -0
- package/dist/commands/domains/create.d.ts +6 -0
- package/dist/commands/domains/create.js +187 -0
- package/dist/commands/domains/delete.d.ts +6 -0
- package/dist/commands/domains/delete.js +40 -0
- package/dist/commands/domains/get.d.ts +19 -0
- package/dist/commands/domains/get.js +142 -0
- package/dist/commands/domains/update.d.ts +11 -0
- package/dist/commands/domains/update.js +163 -0
- package/dist/commands/numbers/create.d.ts +6 -0
- package/dist/commands/numbers/create.js +171 -0
- package/dist/commands/numbers/delete.d.ts +6 -0
- package/dist/commands/numbers/delete.js +40 -0
- package/dist/commands/numbers/get.d.ts +19 -0
- package/dist/commands/numbers/get.js +147 -0
- package/dist/commands/numbers/update.d.ts +11 -0
- package/dist/commands/numbers/update.js +130 -0
- package/dist/commands/peers/create.d.ts +6 -0
- package/dist/commands/peers/create.js +177 -0
- package/dist/commands/peers/delete.d.ts +6 -0
- package/dist/commands/peers/delete.js +40 -0
- package/dist/commands/peers/get.d.ts +19 -0
- package/dist/commands/peers/get.js +159 -0
- package/dist/commands/peers/update.d.ts +11 -0
- package/dist/commands/peers/update.js +156 -0
- package/dist/commands/trunks/create.d.ts +6 -0
- package/dist/commands/trunks/create.js +231 -0
- package/dist/commands/trunks/delete.d.ts +6 -0
- package/dist/commands/trunks/delete.js +40 -0
- package/dist/commands/trunks/get.d.ts +19 -0
- package/dist/commands/trunks/get.js +145 -0
- package/dist/commands/trunks/update.d.ts +11 -0
- package/dist/commands/trunks/update.js +217 -0
- package/dist/countries.d.ts +4 -0
- package/dist/countries.js +270 -0
- package/dist/delete.d.ts +9 -0
- package/dist/delete.js +46 -0
- package/dist/help.d.ts +6 -0
- package/dist/help.js +84 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -0
- package/dist/utils.d.ts +22 -0
- package/dist/utils.js +97 -0
- package/dist/validators.d.ts +16 -0
- package/dist/validators.js +180 -0
- package/oclif.manifest.json +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,40 @@
|
|
|
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 delete_1 = __importDefault(require("../../delete"));
|
|
26
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
27
|
+
class DeleteCrendentialsCommand extends delete_1.default {
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(DeleteCrendentialsCommand);
|
|
30
|
+
const { endpoint, insecure } = flags;
|
|
31
|
+
await super.deleteResource(new sdk_1.default.Credentials({ endpoint, insecure }), "deleteCredentials");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = DeleteCrendentialsCommand;
|
|
35
|
+
DeleteCrendentialsCommand.description = "Deletes a set of Credentials";
|
|
36
|
+
DeleteCrendentialsCommand.examples = [
|
|
37
|
+
`<%= config.bin %> <%= command.id %>
|
|
38
|
+
Deleting item 80181ca6-d4aa-4575-9375-8f72b071111... Done
|
|
39
|
+
`
|
|
40
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from "../../base";
|
|
2
|
+
import { CommandError } from "@oclif/core/lib/interfaces";
|
|
3
|
+
export default class GetCommand extends BaseCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
size: import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
8
|
+
};
|
|
9
|
+
static args: {
|
|
10
|
+
name: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
description: string;
|
|
13
|
+
}[];
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
catch(error: {
|
|
16
|
+
code: number;
|
|
17
|
+
message: string;
|
|
18
|
+
} | CommandError): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
/*
|
|
27
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
28
|
+
* http://github.com/fonoster
|
|
29
|
+
*
|
|
30
|
+
* This file is part of Routr.
|
|
31
|
+
*
|
|
32
|
+
* Licensed under the MIT License (the "License");
|
|
33
|
+
* you may not use this file except in compliance with
|
|
34
|
+
* the License. You may obtain a copy of the License at
|
|
35
|
+
*
|
|
36
|
+
* https://opensource.org/licenses/MIT
|
|
37
|
+
*
|
|
38
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
39
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
40
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
41
|
+
* See the License for the specific language governing permissions and
|
|
42
|
+
* limitations under the License.
|
|
43
|
+
*/
|
|
44
|
+
/* eslint-disable require-jsdoc */
|
|
45
|
+
const core_1 = require("@oclif/core");
|
|
46
|
+
const base_1 = require("../../base");
|
|
47
|
+
const utils_1 = require("../../utils");
|
|
48
|
+
const common_1 = require("@routr/common");
|
|
49
|
+
const errors_1 = require("@oclif/core/lib/errors");
|
|
50
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
51
|
+
class GetCommand extends base_1.BaseCommand {
|
|
52
|
+
async run() {
|
|
53
|
+
const { args, flags } = await this.parse(GetCommand);
|
|
54
|
+
const showTable = (request) => {
|
|
55
|
+
const { showHeader, data, self, flags } = request;
|
|
56
|
+
core_1.CliUx.ux.table(data, {
|
|
57
|
+
ref: {
|
|
58
|
+
minWidth: 7,
|
|
59
|
+
extended: true
|
|
60
|
+
},
|
|
61
|
+
name: {
|
|
62
|
+
minWidth: 7
|
|
63
|
+
},
|
|
64
|
+
username: {
|
|
65
|
+
header: "Username"
|
|
66
|
+
},
|
|
67
|
+
createdAt: {
|
|
68
|
+
header: "Created",
|
|
69
|
+
get: (row) => new Date(row.createdAt * 1000),
|
|
70
|
+
extended: true
|
|
71
|
+
},
|
|
72
|
+
updatedAt: {
|
|
73
|
+
header: "Updated",
|
|
74
|
+
get: (row) => new Date(row.updatedAt * 1000),
|
|
75
|
+
extended: true
|
|
76
|
+
},
|
|
77
|
+
extended: {
|
|
78
|
+
header: "Extended",
|
|
79
|
+
get: (row) => row.extended || {},
|
|
80
|
+
extended: true
|
|
81
|
+
},
|
|
82
|
+
apiVersion: {
|
|
83
|
+
header: "API",
|
|
84
|
+
extended: true
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
"no-header": !showHeader,
|
|
88
|
+
printLine: self.log.bind(self),
|
|
89
|
+
...flags // parsed flags
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
await (0, utils_1.showPaginatedList)({
|
|
93
|
+
showTable,
|
|
94
|
+
args,
|
|
95
|
+
flags,
|
|
96
|
+
kind: common_1.CommonConnect.Kind.CREDENTIALS,
|
|
97
|
+
self: this
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async catch(error) {
|
|
101
|
+
// To be handled globally
|
|
102
|
+
if ("code" in error && error.code === grpc.status.NOT_FOUND) {
|
|
103
|
+
const { args } = await this.parse(GetCommand);
|
|
104
|
+
throw new errors_1.CLIError("the resource you are looking for does not exist: " + args.ref);
|
|
105
|
+
}
|
|
106
|
+
throw new errors_1.CLIError(error.message);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.default = GetCommand;
|
|
110
|
+
GetCommand.description = "Shows a list of paginated Credentials or a single set if ref is provided";
|
|
111
|
+
GetCommand.examples = [
|
|
112
|
+
`<%= config.bin %> <%= command.id %>
|
|
113
|
+
Ref Name Deny List Allow List
|
|
114
|
+
80181ca6-d4aa-4575-9375-8f72b07d6666 Europe ACL 0.0.0.0/0 10.0.0.25
|
|
115
|
+
`
|
|
116
|
+
];
|
|
117
|
+
GetCommand.flags = {
|
|
118
|
+
size: core_1.Flags.integer({
|
|
119
|
+
char: "s",
|
|
120
|
+
description: "the number of items to return",
|
|
121
|
+
default: 50
|
|
122
|
+
})
|
|
123
|
+
};
|
|
124
|
+
GetCommand.args = [
|
|
125
|
+
{
|
|
126
|
+
name: "ref",
|
|
127
|
+
required: false,
|
|
128
|
+
description: "optional reference to a set of Credentials"
|
|
129
|
+
}
|
|
130
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommand } from "../../base";
|
|
2
|
+
export default class UpdateCommand extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
name: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
description: string;
|
|
9
|
+
}[];
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 core_1 = require("@oclif/core");
|
|
26
|
+
const base_1 = require("../../base");
|
|
27
|
+
const errors_1 = require("@oclif/core/lib/errors");
|
|
28
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
29
|
+
// NOTE: Newer versions of inquirer have a bug that causes the following error:
|
|
30
|
+
// (node:75345) [ERR_REQUIRE_ESM] Error Plugin: @routr/ctl [ERR_REQUIRE_ESM]: require() of ES Module
|
|
31
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
32
|
+
const validators_1 = require("../../validators");
|
|
33
|
+
class UpdateCommand extends base_1.BaseCommand {
|
|
34
|
+
async run() {
|
|
35
|
+
const { args, flags } = await this.parse(UpdateCommand);
|
|
36
|
+
const { endpoint, insecure } = flags;
|
|
37
|
+
const api = new sdk_1.default.Credentials({ endpoint, insecure });
|
|
38
|
+
this.log("This utility will help you update an existing set of Credentials.");
|
|
39
|
+
this.log("Press ^C at any time to quit.");
|
|
40
|
+
const credentialsFromDB = await api.getCredentials(args.ref);
|
|
41
|
+
const answers = await inquirer_1.default.prompt([
|
|
42
|
+
{
|
|
43
|
+
name: "name",
|
|
44
|
+
message: "Friendly Name",
|
|
45
|
+
type: "input",
|
|
46
|
+
default: credentialsFromDB.name,
|
|
47
|
+
validate: validators_1.nameValidator
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "username",
|
|
51
|
+
message: "Username",
|
|
52
|
+
type: "input",
|
|
53
|
+
default: credentialsFromDB.username,
|
|
54
|
+
validate: validators_1.usernameValidator
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "password",
|
|
58
|
+
message: "Password",
|
|
59
|
+
type: "password"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "confirm",
|
|
63
|
+
message: "Ready?",
|
|
64
|
+
type: "confirm"
|
|
65
|
+
}
|
|
66
|
+
]);
|
|
67
|
+
answers.ref = args.ref;
|
|
68
|
+
if (!answers.confirm) {
|
|
69
|
+
this.warn("Aborted");
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
try {
|
|
73
|
+
core_1.CliUx.ux.action.start(`Updating Credentials for ${answers.name}`);
|
|
74
|
+
const acl = await api.updateCredentials(answers);
|
|
75
|
+
await core_1.CliUx.ux.wait(1000);
|
|
76
|
+
core_1.CliUx.ux.action.stop(acl.ref);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
core_1.CliUx.ux.action.stop();
|
|
80
|
+
throw new errors_1.CLIError(e.message);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.default = UpdateCommand;
|
|
86
|
+
UpdateCommand.description = "Updates an existing set of Credentials";
|
|
87
|
+
UpdateCommand.examples = [
|
|
88
|
+
`<%= config.bin %> <%= command.id %>
|
|
89
|
+
Updating Credentials JDoe Credentials... 80181ca6-d4aa-4575-9375-8f72b07d5555
|
|
90
|
+
`
|
|
91
|
+
];
|
|
92
|
+
UpdateCommand.args = [
|
|
93
|
+
{
|
|
94
|
+
name: "ref",
|
|
95
|
+
required: true,
|
|
96
|
+
description: "reference to an existing set of Credentials"
|
|
97
|
+
}
|
|
98
|
+
];
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
/*
|
|
30
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
31
|
+
* http://github.com/fonoster
|
|
32
|
+
*
|
|
33
|
+
* This file is part of Routr.
|
|
34
|
+
*
|
|
35
|
+
* Licensed under the MIT License (the "License");
|
|
36
|
+
* you may not use this file except in compliance with
|
|
37
|
+
* the License. You may obtain a copy of the License at
|
|
38
|
+
*
|
|
39
|
+
* https://opensource.org/licenses/MIT
|
|
40
|
+
*
|
|
41
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
43
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
+
* See the License for the specific language governing permissions and
|
|
45
|
+
* limitations under the License.
|
|
46
|
+
*/
|
|
47
|
+
/* eslint-disable require-jsdoc */
|
|
48
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
49
|
+
const core_1 = require("@oclif/core");
|
|
50
|
+
const base_1 = require("../../base");
|
|
51
|
+
const errors_1 = require("@oclif/core/lib/errors");
|
|
52
|
+
const validators_1 = require("../../validators");
|
|
53
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
54
|
+
// NOTE: Newer versions of inquirer have a bug that causes the following error:
|
|
55
|
+
// (node:75345) [ERR_REQUIRE_ESM] Error Plugin: @routr/ctl [ERR_REQUIRE_ESM]: require() of ES Module
|
|
56
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
57
|
+
class CreateCommand extends base_1.BaseCommand {
|
|
58
|
+
async run() {
|
|
59
|
+
const { flags } = await this.parse(CreateCommand);
|
|
60
|
+
const { endpoint, insecure } = flags;
|
|
61
|
+
this.log("This utility will help you create a new Domain.");
|
|
62
|
+
this.log("Press ^C at any time to quit.");
|
|
63
|
+
// TODO: Fix hardcoded pageSize
|
|
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
|
+
// TODO: Fix hardcoded pageSize
|
|
75
|
+
const numbers = await new sdk_1.default.Numbers({ endpoint, insecure }).listNumbers({
|
|
76
|
+
pageSize: 25,
|
|
77
|
+
pageToken: ""
|
|
78
|
+
});
|
|
79
|
+
const numberChoices = numbers.items.map((number) => {
|
|
80
|
+
return {
|
|
81
|
+
name: number.name,
|
|
82
|
+
value: number.ref
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
const group1 = 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: "domainUri",
|
|
94
|
+
message: "SIP URI",
|
|
95
|
+
type: "input",
|
|
96
|
+
validate: validators_1.domainUriValidator
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "accessControlListRef",
|
|
100
|
+
message: "IP Access Control List",
|
|
101
|
+
type: "list",
|
|
102
|
+
choices: [{ name: "None", value: undefined }, ...aclChoices]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "addEgressRule",
|
|
106
|
+
message: "Add an Egress Rule?",
|
|
107
|
+
type: "confirm",
|
|
108
|
+
default: false,
|
|
109
|
+
when: numberChoices.length > 0
|
|
110
|
+
}
|
|
111
|
+
]);
|
|
112
|
+
const group2Questions = [
|
|
113
|
+
{
|
|
114
|
+
name: "numberRef",
|
|
115
|
+
message: "Number",
|
|
116
|
+
type: "list",
|
|
117
|
+
choices: [{ name: "None", value: undefined }, ...numberChoices],
|
|
118
|
+
when: numberChoices.length > 0
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "rule",
|
|
122
|
+
message: "Rule",
|
|
123
|
+
type: "input",
|
|
124
|
+
default: ".*",
|
|
125
|
+
when: (answers) => answers.numberRef
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "addEgressRule",
|
|
129
|
+
message: "Add another Egress Rule?",
|
|
130
|
+
type: "confirm",
|
|
131
|
+
default: false,
|
|
132
|
+
when: (answers) => answers.numberRef
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
let addEgressRule = group1.addEgressRule;
|
|
136
|
+
const egressPolicies = [];
|
|
137
|
+
// eslint-disable-next-line no-loops/no-loops
|
|
138
|
+
while (addEgressRule) {
|
|
139
|
+
const group2 = await inquirer_1.default.prompt(group2Questions);
|
|
140
|
+
if (group2.numberRef) {
|
|
141
|
+
egressPolicies.push({
|
|
142
|
+
numberRef: group2.numberRef,
|
|
143
|
+
rule: group2.rule
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
addEgressRule = group2.addEgressRule;
|
|
147
|
+
}
|
|
148
|
+
const group3 = await inquirer_1.default.prompt([
|
|
149
|
+
{
|
|
150
|
+
name: "confirm",
|
|
151
|
+
message: "Ready?",
|
|
152
|
+
type: "confirm"
|
|
153
|
+
}
|
|
154
|
+
]);
|
|
155
|
+
if (!group3.confirm) {
|
|
156
|
+
this.warn("Aborted");
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
try {
|
|
160
|
+
core_1.CliUx.ux.action.start(`Creating Domain ${group1.name}`);
|
|
161
|
+
const api = new sdk_1.default.Domains({ endpoint, insecure });
|
|
162
|
+
const domains = await api.createDomain({
|
|
163
|
+
...group1,
|
|
164
|
+
egressPolicies
|
|
165
|
+
});
|
|
166
|
+
await core_1.CliUx.ux.wait(1000);
|
|
167
|
+
core_1.CliUx.ux.action.stop(domains.ref);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
core_1.CliUx.ux.action.stop();
|
|
171
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
172
|
+
throw new errors_1.CLIError("This Domain already exist");
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
throw new errors_1.CLIError(e.message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.default = CreateCommand;
|
|
182
|
+
CreateCommand.description = "Creates a new set Domain";
|
|
183
|
+
CreateCommand.examples = [
|
|
184
|
+
`<%= config.bin %> <%= command.id %>
|
|
185
|
+
Creating Domain Local Domain... b148b4b4-6884-4c06-bb7e-bd098f5fe793
|
|
186
|
+
`
|
|
187
|
+
];
|
|
@@ -0,0 +1,40 @@
|
|
|
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 delete_1 = __importDefault(require("../../delete"));
|
|
26
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
27
|
+
class DeleteDomainCommand extends delete_1.default {
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(DeleteDomainCommand);
|
|
30
|
+
const { endpoint, insecure } = flags;
|
|
31
|
+
await super.deleteResource(new sdk_1.default.Domains({ endpoint, insecure }), "deleteDomain");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = DeleteDomainCommand;
|
|
35
|
+
DeleteDomainCommand.description = "Deletes a Domain";
|
|
36
|
+
DeleteDomainCommand.examples = [
|
|
37
|
+
`<%= config.bin %> <%= command.id %>
|
|
38
|
+
Deleting item 80181ca6-d4aa-4575-9375-8f72b071111... Done
|
|
39
|
+
`
|
|
40
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from "../../base";
|
|
2
|
+
import { CommandError } from "@oclif/core/lib/interfaces";
|
|
3
|
+
export default class GetDomainsCommand extends BaseCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
size: import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
8
|
+
};
|
|
9
|
+
static args: {
|
|
10
|
+
name: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
description: string;
|
|
13
|
+
}[];
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
catch(error: {
|
|
16
|
+
code: number;
|
|
17
|
+
message: string;
|
|
18
|
+
} | CommandError): Promise<void>;
|
|
19
|
+
}
|