@dishantlangayan/solace-cloud-cli 0.0.1 → 0.0.3
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 +146 -37
- package/dist/commands/missionctrl/broker/create.d.ts +5 -3
- package/dist/commands/missionctrl/broker/create.js +34 -29
- package/dist/commands/missionctrl/broker/delete.d.ts +5 -3
- package/dist/commands/missionctrl/broker/delete.js +6 -5
- package/dist/commands/missionctrl/broker/display.d.ts +4 -3
- package/dist/commands/missionctrl/broker/display.js +11 -15
- package/dist/commands/missionctrl/broker/list.d.ts +4 -3
- package/dist/commands/missionctrl/broker/list.js +14 -10
- package/dist/commands/missionctrl/broker/opstatus.d.ts +15 -0
- package/dist/commands/missionctrl/broker/opstatus.js +109 -0
- package/dist/commands/platform/env/create.d.ts +4 -3
- package/dist/commands/platform/env/create.js +20 -20
- package/dist/commands/platform/env/delete.d.ts +5 -3
- package/dist/commands/platform/env/delete.js +29 -11
- package/dist/commands/platform/env/display.d.ts +4 -3
- package/dist/commands/platform/env/display.js +22 -21
- package/dist/commands/platform/env/list.d.ts +2 -1
- package/dist/commands/platform/env/list.js +18 -15
- package/dist/commands/platform/env/update.d.ts +4 -3
- package/dist/commands/platform/env/update.js +26 -20
- package/dist/types/broker.d.ts +25 -0
- package/dist/util/internal.d.ts +12 -0
- package/dist/util/internal.js +31 -0
- package/oclif.manifest.json +285 -12
- package/package.json +3 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
2
|
+
import { EventBrokerServiceDetail } from '../../../types/broker.js';
|
|
3
|
+
export default class MissionctrlBrokerList extends ScCommand<typeof MissionctrlBrokerList> {
|
|
3
4
|
static args: {};
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -9,5 +10,5 @@ export default class MissionctrlBrokerList extends Command {
|
|
|
9
10
|
pageSize: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
};
|
|
12
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<EventBrokerServiceDetail[]>;
|
|
13
14
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
3
|
+
import { renderTable } from '../../../util/internal.js';
|
|
3
4
|
import { ScConnection } from '../../../util/sc-connection.js';
|
|
4
|
-
export default class MissionctrlBrokerList extends
|
|
5
|
+
export default class MissionctrlBrokerList extends ScCommand {
|
|
5
6
|
static args = {};
|
|
6
7
|
static description = `Get a listing of event broker services.
|
|
7
8
|
|
|
@@ -10,17 +11,18 @@ Your token must have one of the permissions listed in the Token Permissions.
|
|
|
10
11
|
Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \`services:get:self\` **or** \`services:view\` **or** \`services:view:self\` ]`;
|
|
11
12
|
static examples = ['<%= config.bin %> <%= command.id %> --name=MyBrokerName --pageNumber=1 --pageSize=10 --sort=name:asc'];
|
|
12
13
|
static flags = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
name: Flags.string({
|
|
15
|
+
char: 'n',
|
|
16
|
+
description: 'Name of the event broker service to match on.'
|
|
17
|
+
}),
|
|
18
|
+
pageNumber: Flags.integer({
|
|
19
|
+
description: 'The page number to get. Defaults to 1'
|
|
20
|
+
}),
|
|
18
21
|
pageSize: Flags.integer({
|
|
19
22
|
description: 'The number of event broker services to return per page. Defaults to 100',
|
|
20
23
|
max: 100,
|
|
21
24
|
min: 1,
|
|
22
25
|
}),
|
|
23
|
-
// sort (--sort=VALUE)
|
|
24
26
|
sort: Flags.string({
|
|
25
27
|
description: `Sort the returned event broker services by attribute.
|
|
26
28
|
|
|
@@ -60,6 +62,8 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
|
|
|
60
62
|
];
|
|
61
63
|
// Display results as a table
|
|
62
64
|
this.log();
|
|
63
|
-
this.log(
|
|
65
|
+
this.log(renderTable(brokerArray));
|
|
66
|
+
// Return raw json if --json flag is set
|
|
67
|
+
return resp.data;
|
|
64
68
|
}
|
|
65
69
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
2
|
+
import { OperationData } from '../../../types/broker.js';
|
|
3
|
+
export default class MissionctrlBrokerOpstatus extends ScCommand<typeof MissionctrlBrokerOpstatus> {
|
|
4
|
+
static args: {};
|
|
5
|
+
static description: string;
|
|
6
|
+
static examples: string[];
|
|
7
|
+
static flags: {
|
|
8
|
+
'broker-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'operation-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'show-progress': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<OperationData>;
|
|
14
|
+
private print;
|
|
15
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import cliProgress from 'cli-progress';
|
|
3
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
4
|
+
import { ScConnection } from '../../../util/sc-connection.js';
|
|
5
|
+
import { camelCaseToTitleCase, renderKeyValueTable, sleep } from '../../../util/internal.js';
|
|
6
|
+
export default class MissionctrlBrokerOpstatus extends ScCommand {
|
|
7
|
+
static args = {};
|
|
8
|
+
static description = `Get the status of an operation that being performed on an event broker service.
|
|
9
|
+
To get the operation, you provide identifier of the operation and the identifier of the event broker service.
|
|
10
|
+
|
|
11
|
+
Token Permissions: [ mission_control:access or services:get or services:get:self or services:view or services:view:self ]`;
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> <%= command.id %>',
|
|
14
|
+
];
|
|
15
|
+
static flags = {
|
|
16
|
+
'broker-id': Flags.string({
|
|
17
|
+
char: 'b',
|
|
18
|
+
description: 'Id of the event broker service.',
|
|
19
|
+
exactlyOne: ['broker-id', 'name'],
|
|
20
|
+
}),
|
|
21
|
+
name: Flags.string({
|
|
22
|
+
char: 'n',
|
|
23
|
+
description: 'Name of the event broker service.',
|
|
24
|
+
exactlyOne: ['broker-id', 'name'],
|
|
25
|
+
}),
|
|
26
|
+
'operation-id': Flags.string({
|
|
27
|
+
char: 'o',
|
|
28
|
+
description: 'The identifier of the operation being performed on the event broker service.'
|
|
29
|
+
}),
|
|
30
|
+
'show-progress': Flags.boolean({
|
|
31
|
+
char: 'p',
|
|
32
|
+
description: 'Displays a status bar of the in-progress operation. The command will wait for completion of each step of the operation.'
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
async run() {
|
|
36
|
+
const { flags } = await this.parse(MissionctrlBrokerOpstatus);
|
|
37
|
+
const name = flags.name ?? '';
|
|
38
|
+
let brokerId = flags['broker-id'] ?? '';
|
|
39
|
+
const operationId = flags['operation-id'] ?? '';
|
|
40
|
+
const showProgress = flags['show-progress'] ?? false;
|
|
41
|
+
const conn = new ScConnection();
|
|
42
|
+
// API url
|
|
43
|
+
let apiUrl = `/missionControl/eventBrokerServices`;
|
|
44
|
+
// If broker name provided, retrieve the broker service id first
|
|
45
|
+
// then retrieve the operation status
|
|
46
|
+
let rawResp;
|
|
47
|
+
if (name) {
|
|
48
|
+
// API call to get broker by name
|
|
49
|
+
apiUrl += `?customAttributes=name=="${name}"`;
|
|
50
|
+
const resp = await conn.get(apiUrl);
|
|
51
|
+
// TODO FUTURE: show status of multiple brokers operations that match the name
|
|
52
|
+
if (resp.data.length > 1) {
|
|
53
|
+
this.error(`Multiple broker services found with: ${name}. Exactly one broker service must match the provided name.`);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
brokerId = resp.data[0]?.id;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// API call to retrieve status of the broker operation
|
|
60
|
+
apiUrl = `/missionControl/eventBrokerServices/${brokerId}/operations/${operationId}`;
|
|
61
|
+
if (showProgress) {
|
|
62
|
+
apiUrl += '?expand=progressLogs';
|
|
63
|
+
}
|
|
64
|
+
let resp = await conn.get(apiUrl);
|
|
65
|
+
this.print(resp.data);
|
|
66
|
+
// Display progress bar for each step included in the progress logs
|
|
67
|
+
// Enable progress bar if set
|
|
68
|
+
if (resp.data.progressLogs && resp.data.progressLogs.length > 0) {
|
|
69
|
+
let progressLogs = resp.data.progressLogs;
|
|
70
|
+
let numSteps = progressLogs.length;
|
|
71
|
+
// Create a new progress bar instance and use shades_classic theme
|
|
72
|
+
const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
|
73
|
+
// start the progress bar with a total value of size of the steps and start value of 0
|
|
74
|
+
progressBar.start(numSteps, 0);
|
|
75
|
+
// Update the progress with the steps completed
|
|
76
|
+
let completedNumSteps = 0;
|
|
77
|
+
while (completedNumSteps < numSteps) {
|
|
78
|
+
// Sleep for 5 seconds before making the next API call
|
|
79
|
+
await sleep(5000);
|
|
80
|
+
// Make another API call to get the lastest progress
|
|
81
|
+
resp = await conn.get(apiUrl);
|
|
82
|
+
if (resp.data.progressLogs) {
|
|
83
|
+
progressLogs = resp.data.progressLogs;
|
|
84
|
+
for (const progressLog of progressLogs) {
|
|
85
|
+
if (progressLog.step === 'success') {
|
|
86
|
+
completedNumSteps++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Update progress bar
|
|
90
|
+
progressBar.update(completedNumSteps);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// stop the progress bar
|
|
97
|
+
progressBar.stop();
|
|
98
|
+
}
|
|
99
|
+
return resp.data;
|
|
100
|
+
}
|
|
101
|
+
print(environment) {
|
|
102
|
+
const tableRows = [
|
|
103
|
+
['Key', 'Value'],
|
|
104
|
+
...Object.entries(environment).map(([key, value]) => [camelCaseToTitleCase(key), value]),
|
|
105
|
+
];
|
|
106
|
+
this.log();
|
|
107
|
+
this.log(renderKeyValueTable(tableRows));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
2
|
+
import { Environment } from '../../../types/environment.js';
|
|
3
|
+
export default class PlatformEnvCreate extends ScCommand<typeof PlatformEnvCreate> {
|
|
3
4
|
static args: {};
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -9,6 +10,6 @@ export default class PlatformEnvCreate extends Command {
|
|
|
9
10
|
isProduction: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
};
|
|
12
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<Environment>;
|
|
13
14
|
private print;
|
|
14
15
|
}
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { camelCaseToTitleCase } from '../../../util/internal.js';
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
3
|
+
import { camelCaseToTitleCase, renderKeyValueTable } from '../../../util/internal.js';
|
|
4
4
|
import { ScConnection } from '../../../util/sc-connection.js';
|
|
5
|
-
export default class PlatformEnvCreate extends
|
|
5
|
+
export default class PlatformEnvCreate extends ScCommand {
|
|
6
6
|
static args = {};
|
|
7
7
|
static description = `Create a new environment.
|
|
8
8
|
|
|
9
9
|
Token Permissions: [ environments:edit ]`;
|
|
10
10
|
static examples = ['<%= config.bin %> <%= command.id %> --name=MyEnvironment --desc="My environment description" --isDefault --isProduction'];
|
|
11
11
|
static flags = {
|
|
12
|
-
desc: Flags.string({
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
desc: Flags.string({
|
|
13
|
+
char: 'd',
|
|
14
|
+
description: 'Description of the environment to create.'
|
|
15
|
+
}),
|
|
16
|
+
isDefault: Flags.boolean({
|
|
17
|
+
description: 'Indicates this is the organization’s default environment.'
|
|
18
|
+
}),
|
|
15
19
|
isProduction: Flags.boolean({
|
|
16
20
|
description: `Indicates this is an organization’s production environment.
|
|
17
21
|
This is an immutable field. If an environment needs to be migrated,
|
|
18
22
|
architecture can be migrated to a new environment with the desired
|
|
19
23
|
environment type instead.`,
|
|
20
24
|
}),
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
name: Flags.string({
|
|
26
|
+
char: 'n',
|
|
27
|
+
description: 'Name of the environment to create.',
|
|
28
|
+
required: true
|
|
29
|
+
}),
|
|
23
30
|
};
|
|
24
31
|
async run() {
|
|
25
32
|
const { flags } = await this.parse(PlatformEnvCreate);
|
|
@@ -42,22 +49,15 @@ export default class PlatformEnvCreate extends Command {
|
|
|
42
49
|
// Display results
|
|
43
50
|
this.log('Environment created successfully.');
|
|
44
51
|
this.print(resp.data);
|
|
52
|
+
// Return raw json if --json flag is set
|
|
53
|
+
return resp.data;
|
|
45
54
|
}
|
|
46
55
|
print(environment) {
|
|
47
|
-
this.log();
|
|
48
56
|
const tableRows = [
|
|
49
57
|
['Key', 'Value'],
|
|
50
58
|
...Object.entries(environment).map(([key, value]) => [camelCaseToTitleCase(key), value]),
|
|
51
59
|
];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
columns: {
|
|
55
|
-
1: { width: 50, wrapWord: true },
|
|
56
|
-
},
|
|
57
|
-
drawHorizontalLine(lineIndex, rowCount) {
|
|
58
|
-
return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
this.log(table(tableRows, config));
|
|
60
|
+
this.log();
|
|
61
|
+
this.log(renderKeyValueTable(tableRows));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class PlatformEnvDelete extends
|
|
1
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
2
|
+
export default class PlatformEnvDelete extends ScCommand<typeof PlatformEnvDelete> {
|
|
3
3
|
static args: {};
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
@@ -7,5 +7,7 @@ export default class PlatformEnvDelete extends Command {
|
|
|
7
7
|
'env-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
};
|
|
10
|
-
run(): Promise<
|
|
10
|
+
run(): Promise<{
|
|
11
|
+
message: string;
|
|
12
|
+
}>;
|
|
11
13
|
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
2
3
|
import { ScConnection } from '../../../util/sc-connection.js';
|
|
3
|
-
export default class PlatformEnvDelete extends
|
|
4
|
+
export default class PlatformEnvDelete extends ScCommand {
|
|
4
5
|
static args = {};
|
|
5
6
|
static description = `Delete an environment using either its name or unique identifier. The default environment cannot be deleted.
|
|
6
7
|
|
|
7
8
|
Token Permissions: [ environments:edit ]`;
|
|
8
9
|
static examples = ['<%= config.bin %> <%= command.id %> --name=MyEnvName', '<%= config.bin %> <%= command.id %> --env-id=MyEnvId'];
|
|
9
10
|
static flags = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
'env-id': Flags.string({
|
|
12
|
+
char: 'e',
|
|
13
|
+
description: 'Id of the environment.',
|
|
14
|
+
exactlyOne: ['env-id', 'name']
|
|
15
|
+
}),
|
|
16
|
+
name: Flags.string({
|
|
17
|
+
char: 'n',
|
|
18
|
+
description: 'Name of the environment.',
|
|
19
|
+
exactlyOne: ['env-id', 'name']
|
|
20
|
+
}),
|
|
14
21
|
};
|
|
15
22
|
async run() {
|
|
16
23
|
const { flags } = await this.parse(PlatformEnvDelete);
|
|
@@ -22,20 +29,31 @@ export default class PlatformEnvDelete extends Command {
|
|
|
22
29
|
let envIdToDelete = envId;
|
|
23
30
|
// If env name provided, get the environment matching provided name and delete. If more than one environment matches, an error will be thrown.
|
|
24
31
|
// If env id provided, delete environment with that id
|
|
32
|
+
let foundMultiple = false;
|
|
25
33
|
if (name) {
|
|
26
34
|
// API call to get environment by name
|
|
27
35
|
const getEnvApiUrl = `${apiUrl}?name=${name}`;
|
|
28
36
|
const resp = await conn.get(getEnvApiUrl);
|
|
29
37
|
if (resp.data.length > 1) {
|
|
30
|
-
|
|
38
|
+
foundMultiple = true;
|
|
31
39
|
}
|
|
32
40
|
else {
|
|
33
41
|
envIdToDelete = resp.data[0]?.id;
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
let message = '';
|
|
45
|
+
if (foundMultiple) {
|
|
46
|
+
message = `Multiple environments found with: ${name}. Exactly one environment must match the provided name.`;
|
|
47
|
+
this.warn(message);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// API call to delete environment by id
|
|
51
|
+
apiUrl += `/${envIdToDelete}`;
|
|
52
|
+
await conn.delete(apiUrl);
|
|
53
|
+
message = `Environment with id '${envIdToDelete}' has been deleted successfully.`;
|
|
54
|
+
this.log(message);
|
|
55
|
+
}
|
|
56
|
+
// Return raw json if --json flag is set
|
|
57
|
+
return { message };
|
|
40
58
|
}
|
|
41
59
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
2
|
+
import { Environment } from '../../../types/environment.js';
|
|
3
|
+
export default class PlatformEnvDisplay extends ScCommand<typeof PlatformEnvDisplay> {
|
|
3
4
|
static args: {};
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -7,6 +8,6 @@ export default class PlatformEnvDisplay extends Command {
|
|
|
7
8
|
'env-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
9
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
};
|
|
10
|
-
run(): Promise<
|
|
11
|
+
run(): Promise<Environment[]>;
|
|
11
12
|
private print;
|
|
12
13
|
}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { camelCaseToTitleCase } from '../../../util/internal.js';
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
3
|
+
import { camelCaseToTitleCase, renderKeyValueTable } from '../../../util/internal.js';
|
|
4
4
|
import { ScConnection } from '../../../util/sc-connection.js';
|
|
5
|
-
export default class PlatformEnvDisplay extends
|
|
5
|
+
export default class PlatformEnvDisplay extends ScCommand {
|
|
6
6
|
static args = {};
|
|
7
7
|
static description = `Display information about an Environment.
|
|
8
8
|
|
|
9
9
|
Use either the Environment's ID (--env-id) or name of the Environment (--name).
|
|
10
10
|
|
|
11
|
-
Required token permissions: [ environments:view ]
|
|
12
|
-
`;
|
|
11
|
+
Required token permissions: [ environments:view ]`;
|
|
13
12
|
static examples = ['<%= config.bin %> <%= command.id %> --name=MyEnvName', '<%= config.bin %> <%= command.id %> --env-id=MyEnvId'];
|
|
14
13
|
static flags = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
'env-id': Flags.string({
|
|
15
|
+
char: 'e',
|
|
16
|
+
description: 'Id of the environment.',
|
|
17
|
+
exactlyOne: ['env-id', 'name']
|
|
18
|
+
}),
|
|
19
|
+
name: Flags.string({
|
|
20
|
+
char: 'n',
|
|
21
|
+
description: 'Name of the environment.',
|
|
22
|
+
exactlyOne: ['env-id', 'name']
|
|
23
|
+
}),
|
|
19
24
|
};
|
|
20
25
|
async run() {
|
|
21
26
|
const { flags } = await this.parse(PlatformEnvDisplay);
|
|
@@ -26,11 +31,13 @@ export default class PlatformEnvDisplay extends Command {
|
|
|
26
31
|
// If env name provided, get all environments matching provided name
|
|
27
32
|
// If env id provided, get environment with that id
|
|
28
33
|
let apiUrl = `/platform/environments`;
|
|
34
|
+
let rawResp;
|
|
29
35
|
if (envId) {
|
|
30
36
|
// API call to get environment by id
|
|
31
37
|
apiUrl += `/${envId}`;
|
|
32
38
|
const resp = await conn.get(apiUrl);
|
|
33
39
|
this.print(resp.data);
|
|
40
|
+
rawResp = [resp.data];
|
|
34
41
|
}
|
|
35
42
|
else if (name) {
|
|
36
43
|
// API call to get environment by name
|
|
@@ -39,26 +46,20 @@ export default class PlatformEnvDisplay extends Command {
|
|
|
39
46
|
for (const env of resp.data) {
|
|
40
47
|
this.print(env);
|
|
41
48
|
}
|
|
49
|
+
rawResp = resp.data;
|
|
42
50
|
}
|
|
43
51
|
else {
|
|
44
52
|
this.error('Either --env-id or --name must be provided.');
|
|
45
53
|
}
|
|
54
|
+
// Return raw json if --json flag is set
|
|
55
|
+
return rawResp;
|
|
46
56
|
}
|
|
47
57
|
print(environment) {
|
|
48
|
-
this.log();
|
|
49
58
|
const tableRows = [
|
|
50
59
|
['Key', 'Value'],
|
|
51
60
|
...Object.entries(environment).map(([key, value]) => [camelCaseToTitleCase(key), value]),
|
|
52
61
|
];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
columns: {
|
|
56
|
-
1: { width: 50, wrapWord: true },
|
|
57
|
-
},
|
|
58
|
-
drawHorizontalLine(lineIndex, rowCount) {
|
|
59
|
-
return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
this.log(table(tableRows, config));
|
|
62
|
+
this.log();
|
|
63
|
+
this.log(renderKeyValueTable(tableRows));
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ScCommand } from '../../../sc-command.js';
|
|
2
|
+
import { Environment } from '../../../types/environment.js';
|
|
2
3
|
export default class PlatformEnvList extends ScCommand<typeof PlatformEnvList> {
|
|
3
4
|
static args: {};
|
|
4
5
|
static description: string;
|
|
@@ -9,5 +10,5 @@ export default class PlatformEnvList extends ScCommand<typeof PlatformEnvList> {
|
|
|
9
10
|
pageSize: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
};
|
|
12
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<Environment[]>;
|
|
13
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { table } from 'table';
|
|
3
2
|
import { ScCommand } from '../../../sc-command.js';
|
|
3
|
+
import { renderTable } from '../../../util/internal.js';
|
|
4
4
|
import { ScConnection } from '../../../util/sc-connection.js';
|
|
5
5
|
export default class PlatformEnvList extends ScCommand {
|
|
6
6
|
static args = {};
|
|
@@ -9,17 +9,20 @@ export default class PlatformEnvList extends ScCommand {
|
|
|
9
9
|
Required token permissions: [ environments:view ]`;
|
|
10
10
|
static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --name=Default --pageNumber=1 --pageSize=10 --sort=name:ASC'];
|
|
11
11
|
static flags = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
name: Flags.string({
|
|
13
|
+
char: 'n',
|
|
14
|
+
description: 'Name of the environment to match on.'
|
|
15
|
+
}),
|
|
16
|
+
pageNumber: Flags.integer({
|
|
17
|
+
char: 'p',
|
|
18
|
+
description: 'The page number to get. Defaults to 10'
|
|
19
|
+
}),
|
|
17
20
|
pageSize: Flags.integer({
|
|
21
|
+
char: 's',
|
|
18
22
|
description: 'The number of environments to get per page. Defaults to 1',
|
|
19
23
|
max: 100,
|
|
20
24
|
min: 1,
|
|
21
25
|
}),
|
|
22
|
-
// sort (--sort=VALUE)
|
|
23
26
|
sort: Flags.string({
|
|
24
27
|
description: 'The query (fieldName:<ASC/DESC>) used to sort the environment list in the response.',
|
|
25
28
|
}),
|
|
@@ -37,20 +40,20 @@ export default class PlatformEnvList extends ScCommand {
|
|
|
37
40
|
// API call
|
|
38
41
|
const resp = await conn.get(apiUrl);
|
|
39
42
|
// Array to output as table
|
|
40
|
-
const envArray = [
|
|
43
|
+
const envArray = [
|
|
44
|
+
['Name', 'Id', 'Is Default', 'Is Production', 'Description'],
|
|
45
|
+
...resp.data.map((item) => [
|
|
41
46
|
item.name,
|
|
42
47
|
item.id,
|
|
43
48
|
item.isDefault,
|
|
44
49
|
item.isProduction,
|
|
45
50
|
item.description,
|
|
46
|
-
])
|
|
51
|
+
])
|
|
52
|
+
];
|
|
47
53
|
// Display results as a table
|
|
48
|
-
const config = {
|
|
49
|
-
columns: {
|
|
50
|
-
4: { width: 50, wrapWord: true },
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
54
|
this.log();
|
|
54
|
-
this.log(
|
|
55
|
+
this.log(renderTable(envArray, { 4: { width: 50, wrapWord: true } }));
|
|
56
|
+
// Return raw json if --json flag is set
|
|
57
|
+
return resp.data;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
2
|
+
import { Environment } from '../../../types/environment.js';
|
|
3
|
+
export default class PlatformEnvUpdate extends ScCommand<typeof PlatformEnvUpdate> {
|
|
3
4
|
static args: {};
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
@@ -10,6 +11,6 @@ export default class PlatformEnvUpdate extends Command {
|
|
|
10
11
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
'new-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
};
|
|
13
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<Environment>;
|
|
14
15
|
private print;
|
|
15
16
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { camelCaseToTitleCase } from '../../../util/internal.js';
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { ScCommand } from '../../../sc-command.js';
|
|
3
|
+
import { camelCaseToTitleCase, renderKeyValueTable } from '../../../util/internal.js';
|
|
4
4
|
import { ScConnection } from '../../../util/sc-connection.js';
|
|
5
|
-
export default class PlatformEnvUpdate extends
|
|
5
|
+
export default class PlatformEnvUpdate extends ScCommand {
|
|
6
6
|
static args = {};
|
|
7
7
|
static description = `Modify an environment's attributes
|
|
8
8
|
|
|
@@ -15,11 +15,25 @@ export default class PlatformEnvUpdate extends Command {
|
|
|
15
15
|
'<%= config.bin %> <%= command.id %> --env-id=MyEnvId --new-name=MyNewEnvName --desc="My description to update" --isDefault'
|
|
16
16
|
];
|
|
17
17
|
static flags = {
|
|
18
|
-
desc: Flags.string({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'
|
|
18
|
+
desc: Flags.string({
|
|
19
|
+
char: 'd',
|
|
20
|
+
description: 'Description of the environment to update.'
|
|
21
|
+
}),
|
|
22
|
+
'env-id': Flags.string({
|
|
23
|
+
char: 'e',
|
|
24
|
+
description: 'Id of the environment.',
|
|
25
|
+
exactlyOne: ['env-id', 'name']
|
|
26
|
+
}),
|
|
27
|
+
isDefault: Flags.boolean({
|
|
28
|
+
description: `Indicates this is the organization's default environment. The default value is false.`
|
|
29
|
+
}),
|
|
30
|
+
name: Flags.string({
|
|
31
|
+
char: 'n', description: 'Current name of the environment.',
|
|
32
|
+
exactlyOne: ['env-id', 'name']
|
|
33
|
+
}),
|
|
34
|
+
'new-name': Flags.string({
|
|
35
|
+
description: 'New name of the environment.'
|
|
36
|
+
}),
|
|
23
37
|
};
|
|
24
38
|
async run() {
|
|
25
39
|
const { flags } = await this.parse(PlatformEnvUpdate);
|
|
@@ -55,22 +69,14 @@ export default class PlatformEnvUpdate extends Command {
|
|
|
55
69
|
const resp = await conn.put(apiUrl, body);
|
|
56
70
|
this.log(`Environment with id '${envIdToUdpate}' has been updated successfully.`);
|
|
57
71
|
this.print(resp.data);
|
|
72
|
+
return resp.data;
|
|
58
73
|
}
|
|
59
74
|
print(environment) {
|
|
60
|
-
this.log();
|
|
61
75
|
const tableRows = [
|
|
62
76
|
['Key', 'Value'],
|
|
63
77
|
...Object.entries(environment).map(([key, value]) => [camelCaseToTitleCase(key), value]),
|
|
64
78
|
];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
columns: {
|
|
68
|
-
1: { width: 50, wrapWord: true },
|
|
69
|
-
},
|
|
70
|
-
drawHorizontalLine(lineIndex, rowCount) {
|
|
71
|
-
return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
this.log(table(tableRows, config));
|
|
79
|
+
this.log();
|
|
80
|
+
this.log(renderKeyValueTable(tableRows));
|
|
75
81
|
}
|
|
76
82
|
}
|