@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
package/bin/dev
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const oclif = require('@oclif/core')
|
|
4
|
+
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const project = path.join(__dirname, '..', 'tsconfig.json')
|
|
7
|
+
|
|
8
|
+
// In dev mode -> use ts-node and dev plugins
|
|
9
|
+
process.env.NODE_ENV = 'development'
|
|
10
|
+
|
|
11
|
+
require('ts-node').register({project})
|
|
12
|
+
|
|
13
|
+
// In dev mode, always show stack traces
|
|
14
|
+
oclif.settings.debug = true;
|
|
15
|
+
|
|
16
|
+
// Start the CLI
|
|
17
|
+
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
package/bin/dev.cmd
ADDED
package/bin/run
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
4
|
+
* http://github.com/fonoster
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Routr.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the MIT License (the "License");
|
|
9
|
+
* you may not use this file except in compliance with
|
|
10
|
+
* the License. You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* https://opensource.org/licenses/MIT
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
const oclif = require("@oclif/core")
|
|
21
|
+
|
|
22
|
+
oclif
|
|
23
|
+
.run()
|
|
24
|
+
.then(require("@oclif/core/flush"))
|
|
25
|
+
.catch(require("@oclif/core/handle"))
|
package/bin/run.cmd
ADDED
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export declare abstract class BaseCommand extends Command {
|
|
3
|
+
static globalFlags: {
|
|
4
|
+
extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
5
|
+
insecure: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
endpoint: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
7
|
+
};
|
|
8
|
+
}
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCommand = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Routr.
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
/* eslint-disable require-jsdoc */
|
|
23
|
+
const core_1 = require("@oclif/core");
|
|
24
|
+
class BaseCommand extends core_1.Command {
|
|
25
|
+
}
|
|
26
|
+
exports.BaseCommand = BaseCommand;
|
|
27
|
+
BaseCommand.globalFlags = {
|
|
28
|
+
extended: core_1.Flags.boolean({
|
|
29
|
+
char: "x",
|
|
30
|
+
description: "extended output format"
|
|
31
|
+
}),
|
|
32
|
+
insecure: core_1.Flags.boolean({
|
|
33
|
+
char: "i",
|
|
34
|
+
description: "allow insecure connections to the routr server",
|
|
35
|
+
default: false
|
|
36
|
+
}),
|
|
37
|
+
endpoint: core_1.Flags.string({
|
|
38
|
+
char: "e",
|
|
39
|
+
description: "endpoint to connect to the routr server",
|
|
40
|
+
default: "localhost:51907"
|
|
41
|
+
})
|
|
42
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
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 utils_1 = require("../../utils");
|
|
54
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
55
|
+
// NOTE: Newer versions of inquirer have a bug that causes the following error:
|
|
56
|
+
// (node:75345) [ERR_REQUIRE_ESM] Error Plugin: @routr/ctl [ERR_REQUIRE_ESM]: require() of ES Module
|
|
57
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
58
|
+
class CreateCommand extends base_1.BaseCommand {
|
|
59
|
+
async run() {
|
|
60
|
+
const { flags } = await this.parse(CreateCommand);
|
|
61
|
+
const { endpoint, insecure } = flags;
|
|
62
|
+
this.log("This utility will help you create a new ACL");
|
|
63
|
+
this.log("Press ^C at any time to quit.");
|
|
64
|
+
const answers = await inquirer_1.default.prompt([
|
|
65
|
+
{
|
|
66
|
+
name: "name",
|
|
67
|
+
message: "Friendly Name",
|
|
68
|
+
type: "input",
|
|
69
|
+
validate: validators_1.nameValidator
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "deny",
|
|
73
|
+
message: "Deny CIDR Networks",
|
|
74
|
+
type: "input",
|
|
75
|
+
default: "0.0.0.0/0",
|
|
76
|
+
validate: validators_1.aclRuleValidator
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "allow",
|
|
80
|
+
message: "Allow CIDR Networks",
|
|
81
|
+
type: "input",
|
|
82
|
+
validate: validators_1.aclRuleValidator
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "confirm",
|
|
86
|
+
message: "Ready?",
|
|
87
|
+
type: "confirm"
|
|
88
|
+
}
|
|
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 {
|
|
98
|
+
core_1.CliUx.ux.action.start(`Creating ACL ${answers.name}`);
|
|
99
|
+
const api = new sdk_1.default.ACL({ endpoint, insecure });
|
|
100
|
+
const acl = await api.createACL(answers);
|
|
101
|
+
await core_1.CliUx.ux.wait(1000);
|
|
102
|
+
core_1.CliUx.ux.action.stop(acl.ref);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
core_1.CliUx.ux.action.stop();
|
|
106
|
+
if (e.code === grpc.status.ALREADY_EXISTS) {
|
|
107
|
+
throw new errors_1.CLIError("This ACL already exist");
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new errors_1.CLIError(e.message);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.default = CreateCommand;
|
|
117
|
+
CreateCommand.description = "Creates a new ACL";
|
|
118
|
+
CreateCommand.examples = [
|
|
119
|
+
`<%= config.bin %> <%= command.id %>
|
|
120
|
+
Creating ACL US Eeast... b148b4b4-6884-4c06-bb7e-bd098f5fe793
|
|
121
|
+
`
|
|
122
|
+
];
|
|
@@ -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 CreateCommand extends delete_1.default {
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(CreateCommand);
|
|
30
|
+
const { endpoint, insecure } = flags;
|
|
31
|
+
await super.deleteResource(new sdk_1.default.ACL({ endpoint, insecure }), "deleteACL");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = CreateCommand;
|
|
35
|
+
CreateCommand.description = "Deletes an Access Control List";
|
|
36
|
+
CreateCommand.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,135 @@
|
|
|
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
|
+
deny: {
|
|
65
|
+
header: "Deny CIDR Networks",
|
|
66
|
+
get: (row) => row.deny.join(", ")
|
|
67
|
+
},
|
|
68
|
+
allow: {
|
|
69
|
+
header: "Allow CIDR Networks",
|
|
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
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
"no-header": !showHeader,
|
|
93
|
+
printLine: self.log.bind(self),
|
|
94
|
+
...flags // parsed flags
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
await (0, utils_1.showPaginatedList)({
|
|
98
|
+
showTable,
|
|
99
|
+
args,
|
|
100
|
+
flags,
|
|
101
|
+
kind: common_1.CommonConnect.Kind.ACL,
|
|
102
|
+
self: this
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async catch(error) {
|
|
106
|
+
// To be handled globally
|
|
107
|
+
if ("code" in error && error.code === grpc.status.NOT_FOUND) {
|
|
108
|
+
const { args } = await this.parse(GetCommand);
|
|
109
|
+
throw new errors_1.CLIError("the ACL you are looking for does not exist: " + args.ref);
|
|
110
|
+
}
|
|
111
|
+
throw new errors_1.CLIError(error.message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.default = GetCommand;
|
|
115
|
+
GetCommand.description = "Shows a list of paginated ACLs or a single ACL if a ref is provided";
|
|
116
|
+
GetCommand.examples = [
|
|
117
|
+
`<%= config.bin %> <%= command.id %>
|
|
118
|
+
Ref Name Deny List Allow List
|
|
119
|
+
9e7a88f0-8390-42f5-a2cb-689583ba9f4f Local Network ACL 0.0.0.0/0 10.0.0.28
|
|
120
|
+
`
|
|
121
|
+
];
|
|
122
|
+
GetCommand.flags = {
|
|
123
|
+
size: core_1.Flags.integer({
|
|
124
|
+
char: "s",
|
|
125
|
+
description: "the number of items to return",
|
|
126
|
+
default: 50
|
|
127
|
+
})
|
|
128
|
+
};
|
|
129
|
+
GetCommand.args = [
|
|
130
|
+
{
|
|
131
|
+
name: "ref",
|
|
132
|
+
required: false,
|
|
133
|
+
description: "optional reference to an ACL"
|
|
134
|
+
}
|
|
135
|
+
];
|
|
@@ -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,100 @@
|
|
|
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 validators_1 = require("../../validators");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
30
|
+
const sdk_1 = __importDefault(require("@routr/sdk"));
|
|
31
|
+
// NOTE: Newer versions of inquirer have a bug that causes the following error:
|
|
32
|
+
// (node:75345) [ERR_REQUIRE_ESM] Error Plugin: @routr/ctl [ERR_REQUIRE_ESM]: require() of ES Module
|
|
33
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
34
|
+
class UpdateCommand extends base_1.BaseCommand {
|
|
35
|
+
async run() {
|
|
36
|
+
const { args, flags } = await this.parse(UpdateCommand);
|
|
37
|
+
const { endpoint, insecure } = flags;
|
|
38
|
+
const api = new sdk_1.default.ACL({ endpoint, insecure });
|
|
39
|
+
this.log("This utility will help you update an existing ACL.");
|
|
40
|
+
this.log("Press ^C at any time to quit.");
|
|
41
|
+
const aclFromDB = await api.getACL(args.ref);
|
|
42
|
+
const answers = await inquirer_1.default.prompt([
|
|
43
|
+
{
|
|
44
|
+
name: "name",
|
|
45
|
+
message: "Friendly Name",
|
|
46
|
+
type: "input",
|
|
47
|
+
default: aclFromDB.name,
|
|
48
|
+
validate: validators_1.nameValidator
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "deny",
|
|
52
|
+
message: "Deny CIDR Networks",
|
|
53
|
+
type: "input",
|
|
54
|
+
default: aclFromDB.deny.join(","),
|
|
55
|
+
validate: validators_1.aclRuleValidator
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "allow",
|
|
59
|
+
message: "Allow CIDR Networks",
|
|
60
|
+
type: "input",
|
|
61
|
+
default: aclFromDB.allow.join(","),
|
|
62
|
+
validate: validators_1.aclRuleValidator
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "confirm",
|
|
66
|
+
message: "Ready?",
|
|
67
|
+
type: "confirm"
|
|
68
|
+
}
|
|
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 {
|
|
79
|
+
core_1.CliUx.ux.action.start(`Updating ACL ${answers.name}`);
|
|
80
|
+
const acl = await api.updateACL(answers);
|
|
81
|
+
await core_1.CliUx.ux.wait(1000);
|
|
82
|
+
core_1.CliUx.ux.action.stop(acl.ref);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
core_1.CliUx.ux.action.stop();
|
|
86
|
+
throw new errors_1.CLIError(e.message);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.default = UpdateCommand;
|
|
92
|
+
UpdateCommand.description = "Updates an existing ACL";
|
|
93
|
+
UpdateCommand.examples = [
|
|
94
|
+
`<%= config.bin %> <%= command.id %>
|
|
95
|
+
Updating ACL US East... 80181ca6-d4aa-4575-9375-8f72b07d5555
|
|
96
|
+
`
|
|
97
|
+
];
|
|
98
|
+
UpdateCommand.args = [
|
|
99
|
+
{ name: "ref", required: true, description: "reference to an ACL" }
|
|
100
|
+
];
|