@fonoster/ctl 0.15.16 → 0.15.18
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.
|
@@ -72,6 +72,12 @@ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
73
|
this.log("This utility will help you create a new Domain.");
|
|
74
74
|
this.log("Press ^C at any time to quit.");
|
|
75
|
+
const client = yield this.createSdkClient();
|
|
76
|
+
const acls = new SDK.Acls(client);
|
|
77
|
+
const aclsList = (yield acls.listAcls({ pageSize: 1000 })).items.map((item) => ({
|
|
78
|
+
name: item.name,
|
|
79
|
+
value: item.ref
|
|
80
|
+
}));
|
|
75
81
|
const answers = {
|
|
76
82
|
name: yield (0, prompts_1.input)({
|
|
77
83
|
message: "Name",
|
|
@@ -81,6 +87,10 @@ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
81
87
|
message: "Domain URI",
|
|
82
88
|
required: true
|
|
83
89
|
}),
|
|
90
|
+
accessControlListRef: yield (0, prompts_1.select)({
|
|
91
|
+
message: "Access Control List",
|
|
92
|
+
choices: [{ name: "None", value: null }].concat(aclsList)
|
|
93
|
+
}),
|
|
84
94
|
confirm: yield (0, prompts_1.confirm)({
|
|
85
95
|
message: "Ready?"
|
|
86
96
|
})
|
|
@@ -90,9 +100,12 @@ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
90
100
|
return;
|
|
91
101
|
}
|
|
92
102
|
try {
|
|
93
|
-
const client = yield this.createSdkClient();
|
|
94
103
|
const domains = new SDK.Domains(client);
|
|
95
|
-
|
|
104
|
+
// Filter out null ACL reference
|
|
105
|
+
const request = Object.assign({ name: answers.name, domainUri: answers.domainUri }, (answers.accessControlListRef && {
|
|
106
|
+
accessControlListRef: answers.accessControlListRef
|
|
107
|
+
}));
|
|
108
|
+
yield domains.createDomain(request);
|
|
96
109
|
this.log("Done!");
|
|
97
110
|
}
|
|
98
111
|
catch (e) {
|
|
@@ -83,7 +83,20 @@ class Get extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
83
83
|
`REF: \t${response.ref}\n` +
|
|
84
84
|
`DOMAIN URI: \t${response.domainUri}\n` +
|
|
85
85
|
`CREATED: \t${(0, moment_1.default)(response.createdAt).format("YYYY-MM-DD HH:mm:ss")}\n` +
|
|
86
|
-
`UPDATED: \t${(0, moment_1.default)(response.updatedAt).format("YYYY-MM-DD HH:mm:ss")}`
|
|
86
|
+
`UPDATED: \t${(0, moment_1.default)(response.updatedAt).format("YYYY-MM-DD HH:mm:ss")}\n` +
|
|
87
|
+
(response.accessControlList
|
|
88
|
+
? `\nACCESS CONTROL LIST:\n` +
|
|
89
|
+
` NAME: \t${response.accessControlList.name}\n` +
|
|
90
|
+
` REF: \t${response.accessControlList.ref}\n` +
|
|
91
|
+
` ALLOW: \t${response.accessControlList.allow.join(", ") || "None"}\n` +
|
|
92
|
+
` DENY: \t${response.accessControlList.deny.join(", ") || "None"}`
|
|
93
|
+
: `\nACCESS CONTROL LIST: \tNone`) +
|
|
94
|
+
(response.egressPolicies && response.egressPolicies.length > 0
|
|
95
|
+
? `\n\nEGRESS POLICIES:\n` +
|
|
96
|
+
response.egressPolicies
|
|
97
|
+
.map((policy, index) => ` ${index + 1}. Rule: ${policy.rule}, Number: ${policy.numberRef}`)
|
|
98
|
+
.join("\n")
|
|
99
|
+
: `\n\nEGRESS POLICIES: \tNone`));
|
|
87
100
|
this.log(ui.toString());
|
|
88
101
|
});
|
|
89
102
|
}
|
|
@@ -77,9 +77,14 @@ class List extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
77
77
|
pageSize: parseInt(flags["page-size"])
|
|
78
78
|
});
|
|
79
79
|
const ui = (0, cliui_1.default)({ width: 100 });
|
|
80
|
-
ui.div({ text: "REF", padding: [0, 0, 0, 0], width: 40 }, { text: "NAME", padding: [0, 0, 0, 0], width:
|
|
80
|
+
ui.div({ text: "REF", padding: [0, 0, 0, 0], width: 40 }, { text: "NAME", padding: [0, 0, 0, 0], width: 25 }, { text: "DOMAIN URI", padding: [0, 0, 0, 0], width: 30 }, { text: "ACL", padding: [0, 0, 0, 0], width: 20 });
|
|
81
81
|
response.items.forEach((domain) => {
|
|
82
|
-
|
|
82
|
+
var _a;
|
|
83
|
+
ui.div({ text: domain.ref, padding: [0, 0, 0, 0], width: 40 }, { text: domain.name, padding: [0, 0, 0, 0], width: 25 }, { text: domain.domainUri, padding: [0, 0, 0, 0], width: 30 }, {
|
|
84
|
+
text: ((_a = domain.accessControlList) === null || _a === void 0 ? void 0 : _a.name) || "None",
|
|
85
|
+
padding: [0, 0, 0, 0],
|
|
86
|
+
width: 20
|
|
87
|
+
});
|
|
83
88
|
});
|
|
84
89
|
this.log(ui.toString());
|
|
85
90
|
});
|
|
@@ -71,16 +71,22 @@ const errorHandler_1 = __importDefault(require("../../../errorHandler"));
|
|
|
71
71
|
class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
72
72
|
run() {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a;
|
|
74
75
|
const { args } = yield this.parse(Update);
|
|
75
76
|
const { ref } = args;
|
|
76
77
|
const client = yield this.createSdkClient();
|
|
77
78
|
const domains = new SDK.Domains(client);
|
|
79
|
+
const acls = new SDK.Acls(client);
|
|
78
80
|
const domainFromDb = yield domains.getDomain(ref);
|
|
79
81
|
if (!domainFromDb) {
|
|
80
82
|
this.error("Domain not found.");
|
|
81
83
|
}
|
|
82
84
|
this.log("This utility will help you update an Domain.");
|
|
83
85
|
this.log("Press ^C at any time to quit.");
|
|
86
|
+
const aclsList = (yield acls.listAcls({ pageSize: 1000 })).items.map((item) => ({
|
|
87
|
+
name: item.name,
|
|
88
|
+
value: item.ref
|
|
89
|
+
}));
|
|
84
90
|
const answers = {
|
|
85
91
|
ref,
|
|
86
92
|
name: yield (0, prompts_1.input)({
|
|
@@ -88,6 +94,11 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
88
94
|
required: true,
|
|
89
95
|
default: domainFromDb.name
|
|
90
96
|
}),
|
|
97
|
+
accessControlListRef: yield (0, prompts_1.select)({
|
|
98
|
+
message: "Access Control List",
|
|
99
|
+
choices: [{ name: "None", value: null }].concat(aclsList),
|
|
100
|
+
default: (_a = domainFromDb.accessControlList) === null || _a === void 0 ? void 0 : _a.ref
|
|
101
|
+
}),
|
|
91
102
|
confirm: yield (0, prompts_1.confirm)({
|
|
92
103
|
message: "Ready?"
|
|
93
104
|
})
|
|
@@ -97,7 +108,11 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
97
108
|
return;
|
|
98
109
|
}
|
|
99
110
|
try {
|
|
100
|
-
|
|
111
|
+
// Filter out null ACL reference
|
|
112
|
+
const request = Object.assign({ ref: answers.ref, name: answers.name }, (answers.accessControlListRef && {
|
|
113
|
+
accessControlListRef: answers.accessControlListRef
|
|
114
|
+
}));
|
|
115
|
+
yield domains.updateDomain(request);
|
|
101
116
|
this.log("Done!");
|
|
102
117
|
}
|
|
103
118
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/ctl",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.18",
|
|
4
4
|
"description": "Fonoster Control Tool",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "73b2913268620b8e9d12a151659f951a5346fed8",
|
|
34
34
|
"bin": {
|
|
35
35
|
"fonoster": "./bin/run.js"
|
|
36
36
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@fonoster/sdk": "^0.15.
|
|
54
|
+
"@fonoster/sdk": "^0.15.18",
|
|
55
55
|
"@inquirer/prompts": "^7.1.0",
|
|
56
56
|
"@oclif/core": "^4.0.34",
|
|
57
57
|
"@oclif/plugin-warn-if-update-available": "^3.1.28",
|