@dishantlangayan/solace-cloud-cli 0.2.0 → 0.3.0

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.
Files changed (37) hide show
  1. package/README.md +362 -32
  2. package/dist/commands/account/list.d.ts +10 -0
  3. package/dist/commands/account/list.js +36 -0
  4. package/dist/commands/account/login.d.ts +43 -0
  5. package/dist/commands/account/login.js +232 -0
  6. package/dist/commands/account/logout.d.ts +15 -0
  7. package/dist/commands/account/logout.js +113 -0
  8. package/dist/commands/missionctrl/broker/create.d.ts +1 -0
  9. package/dist/commands/missionctrl/broker/create.js +8 -2
  10. package/dist/commands/missionctrl/broker/delete.d.ts +1 -0
  11. package/dist/commands/missionctrl/broker/delete.js +8 -2
  12. package/dist/commands/missionctrl/broker/display.d.ts +1 -0
  13. package/dist/commands/missionctrl/broker/display.js +11 -3
  14. package/dist/commands/missionctrl/broker/list.d.ts +1 -0
  15. package/dist/commands/missionctrl/broker/list.js +8 -2
  16. package/dist/commands/missionctrl/broker/opstatus.d.ts +1 -0
  17. package/dist/commands/missionctrl/broker/opstatus.js +8 -2
  18. package/dist/commands/missionctrl/broker/state.d.ts +1 -0
  19. package/dist/commands/missionctrl/broker/state.js +8 -2
  20. package/dist/commands/missionctrl/broker/update.d.ts +1 -0
  21. package/dist/commands/missionctrl/broker/update.js +8 -3
  22. package/dist/commands/platform/env/create.d.ts +1 -0
  23. package/dist/commands/platform/env/create.js +9 -3
  24. package/dist/commands/platform/env/delete.d.ts +1 -0
  25. package/dist/commands/platform/env/delete.js +8 -2
  26. package/dist/commands/platform/env/display.d.ts +1 -0
  27. package/dist/commands/platform/env/display.js +8 -2
  28. package/dist/commands/platform/env/list.d.ts +1 -0
  29. package/dist/commands/platform/env/list.js +8 -2
  30. package/dist/commands/platform/env/update.d.ts +1 -0
  31. package/dist/commands/platform/env/update.js +9 -3
  32. package/dist/lib/org-utils.d.ts +24 -0
  33. package/dist/lib/org-utils.js +77 -0
  34. package/oclif.manifest.json +337 -12
  35. package/package.json +21 -3
  36. package/dist/config/env-vars.d.ts +0 -44
  37. package/dist/config/env-vars.js +0 -47
@@ -0,0 +1,36 @@
1
+ import { renderTable, ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ export default class AccountList extends ScCommand {
3
+ static args = {};
4
+ static description = `List all authenticated organizations.
5
+
6
+ Displays organizations you have logged into, including their aliases and which one is set as default.`;
7
+ static examples = [
8
+ '<%= config.bin %> <%= command.id %>',
9
+ ];
10
+ static flags = {};
11
+ async run() {
12
+ const orgManager = await this.getOrgManager();
13
+ // Get all authenticated organizations
14
+ const allOrgs = await orgManager.getAllOrgs();
15
+ // Handle case when no organizations exist
16
+ if (allOrgs.length === 0) {
17
+ this.log("No organizations found. Run 'sc account:login' to authenticate.");
18
+ return { data: [] };
19
+ }
20
+ // Create table array (first row is headers, rest are data rows)
21
+ const orgArray = [
22
+ ['Org ID', 'Alias', 'Base URL', 'API Version', 'Is Default'],
23
+ ...allOrgs.map((org) => [
24
+ org.orgId,
25
+ org.alias ?? '',
26
+ org.baseUrl,
27
+ org.apiVersion ?? '',
28
+ org.isDefault ? 'Yes' : '',
29
+ ]),
30
+ ];
31
+ // Display results as a table
32
+ this.log(renderTable(orgArray));
33
+ // Return raw data for --json flag support
34
+ return { data: allOrgs };
35
+ }
36
+ }
@@ -0,0 +1,43 @@
1
+ import { OrgConfig, ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ export default class AccountLogin extends ScCommand<typeof AccountLogin> {
3
+ static args: {};
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ org: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'set-default': import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ run(): Promise<OrgConfig>;
15
+ /**
16
+ * Creates organization configuration object
17
+ */
18
+ private createOrgConfig;
19
+ /**
20
+ * Displays success message after login
21
+ */
22
+ private displaySuccessMessage;
23
+ /**
24
+ * Checks if entry exists and handles overwrite confirmation
25
+ */
26
+ private handleExistingEntry;
27
+ /**
28
+ * Handles errors during login process
29
+ */
30
+ private handleLoginError;
31
+ /**
32
+ * Obtains access token from environment or user prompt
33
+ */
34
+ private obtainAccessToken;
35
+ /**
36
+ * Prompts user for confirmation with Y/n (default Yes)
37
+ */
38
+ private promptForConfirmation;
39
+ /**
40
+ * Prompts user for access token with hidden input
41
+ */
42
+ private promptForToken;
43
+ }
@@ -0,0 +1,232 @@
1
+ import { OrgError, OrgErrorCode, ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { Flags } from '@oclif/core';
3
+ import * as process from 'node:process';
4
+ import * as readline from 'node:readline';
5
+ const DEFAULT_BASE_URL = 'https://api.solace.cloud';
6
+ export default class AccountLogin extends ScCommand {
7
+ static args = {};
8
+ static description = `Login to a Solace Cloud organization.
9
+
10
+ Stores organization credentials securely using OS keychain.
11
+ The access token is encrypted and stored locally.
12
+
13
+ You can store multiple access tokens for the same organization by using unique aliases.
14
+ Without an alias, only one token per organization ID is allowed.
15
+
16
+ Required token permissions: Varies by operations you intend to perform`;
17
+ static examples = [
18
+ '<%= config.bin %> <%= command.id %> --org=my-org-id',
19
+ '<%= config.bin %> <%= command.id %> --org=my-org-id --alias=production',
20
+ '<%= config.bin %> <%= command.id %> --org=my-org-id --alias=staging',
21
+ '<%= config.bin %> <%= command.id %> --org=my-org-id --set-default',
22
+ '<%= config.bin %> <%= command.id %> --org=my-org-id --no-prompt',
23
+ '<%= config.bin %> <%= command.id %> --org=my-org-id --base-url=https://api.custom.solace.cloud',
24
+ ];
25
+ static flags = {
26
+ 'alias': Flags.string({
27
+ char: 'a',
28
+ description: 'Alias name for this organization (allows storing multiple tokens for the same org with different aliases)',
29
+ }),
30
+ 'api-version': Flags.string({
31
+ description: 'API version to use (optional)',
32
+ }),
33
+ 'base-url': Flags.string({
34
+ description: 'Custom base URL for Solace Cloud API (optional)',
35
+ }),
36
+ 'no-prompt': Flags.boolean({
37
+ default: false,
38
+ description: 'Read access token from SC_ACCESS_TOKEN environment variable instead of prompting',
39
+ }),
40
+ 'org': Flags.string({
41
+ char: 'o',
42
+ description: 'Organization ID to login to',
43
+ required: true,
44
+ }),
45
+ 'set-default': Flags.boolean({
46
+ char: 'd',
47
+ default: false,
48
+ description: 'Set this organization as the default',
49
+ }),
50
+ };
51
+ async run() {
52
+ const { flags } = await this.parse(AccountLogin);
53
+ try {
54
+ const orgManager = await this.getOrgManager();
55
+ const identifier = flags.alias ?? flags.org;
56
+ // Handle existing organization/alias
57
+ const isUpdate = await this.handleExistingEntry(orgManager, identifier, flags.alias);
58
+ // Obtain access token
59
+ const accessToken = await this.obtainAccessToken(flags['no-prompt']);
60
+ // Create and store organization config
61
+ const orgConfig = this.createOrgConfig(flags, accessToken);
62
+ await orgManager.addOrg(orgConfig);
63
+ // Set as default if requested
64
+ if (flags['set-default']) {
65
+ await orgManager.setDefaultOrg(identifier);
66
+ }
67
+ // Display success message
68
+ this.displaySuccessMessage(isUpdate, flags.org, flags.alias, flags['set-default']);
69
+ return orgConfig;
70
+ }
71
+ catch (error) {
72
+ this.handleLoginError(error);
73
+ }
74
+ }
75
+ /**
76
+ * Creates organization configuration object
77
+ */
78
+ createOrgConfig(flags, accessToken) {
79
+ return {
80
+ accessToken,
81
+ alias: flags.alias,
82
+ apiVersion: flags['api-version'],
83
+ baseUrl: flags['base-url'] ?? DEFAULT_BASE_URL,
84
+ orgId: flags.org,
85
+ };
86
+ }
87
+ /**
88
+ * Displays success message after login
89
+ */
90
+ displaySuccessMessage(isUpdate, orgId, alias, setDefault) {
91
+ const action = isUpdate ? 'updated' : 'logged in to';
92
+ const aliasText = alias ? ` (${alias})` : '';
93
+ this.log(`Successfully ${action} organization '${orgId}'${aliasText}`);
94
+ if (setDefault) {
95
+ this.log('Set as default organization.');
96
+ }
97
+ }
98
+ /**
99
+ * Checks if entry exists and handles overwrite confirmation
100
+ */
101
+ async handleExistingEntry(orgManager, identifier, alias) {
102
+ const exists = await orgManager.orgExists(identifier);
103
+ if (!exists) {
104
+ return false;
105
+ }
106
+ const identifierType = alias ? 'alias' : 'organization';
107
+ const identifierDisplay = alias ? `alias '${alias}'` : `organization '${identifier}'`;
108
+ const shouldOverwrite = await this.promptForConfirmation(`${identifierType === 'alias' ? 'An entry with' : 'Organization'} ${identifierDisplay} already exists. Do you want to overwrite the access token?`);
109
+ if (!shouldOverwrite) {
110
+ this.log('Login cancelled.');
111
+ this.exit(0);
112
+ }
113
+ await orgManager.removeOrg(identifier);
114
+ return true;
115
+ }
116
+ /**
117
+ * Handles errors during login process
118
+ */
119
+ handleLoginError(error) {
120
+ if (error instanceof OrgError) {
121
+ switch (error.code) {
122
+ case OrgErrorCode.FILE_WRITE_ERROR: {
123
+ this.error('Failed to save credentials. Please check file permissions.');
124
+ break;
125
+ }
126
+ case OrgErrorCode.INVALID_ACCESS_TOKEN: {
127
+ this.error('Invalid access token format. Please check your token and try again.');
128
+ break;
129
+ }
130
+ case OrgErrorCode.INVALID_ORG_ID: {
131
+ this.error('Invalid organization ID format. Please check and try again.');
132
+ break;
133
+ }
134
+ default: {
135
+ this.error(`Login failed: ${error.message}`);
136
+ break;
137
+ }
138
+ }
139
+ }
140
+ if (error instanceof Error && error.message === 'Cancelled by user') {
141
+ this.error('Login cancelled.');
142
+ }
143
+ // Re-throw unexpected errors
144
+ throw error;
145
+ }
146
+ /**
147
+ * Obtains access token from environment or user prompt
148
+ */
149
+ async obtainAccessToken(noPrompt) {
150
+ if (noPrompt) {
151
+ const accessToken = process.env.SC_ACCESS_TOKEN || '';
152
+ if (!accessToken) {
153
+ this.error('SC_ACCESS_TOKEN environment variable is not set. Please set it or remove the --no-prompt flag.');
154
+ }
155
+ return accessToken;
156
+ }
157
+ return this.promptForToken();
158
+ }
159
+ /**
160
+ * Prompts user for confirmation with Y/n (default Yes)
161
+ */
162
+ async promptForConfirmation(message) {
163
+ const rl = readline.createInterface({
164
+ input: process.stdin,
165
+ output: process.stdout,
166
+ });
167
+ return new Promise((resolve) => {
168
+ rl.question(`${message} (Y/n): `, (answer) => {
169
+ rl.close();
170
+ const normalized = answer.trim().toLowerCase();
171
+ // Default to yes if empty, accept y/yes as confirmation
172
+ const confirmed = normalized === '' || normalized === 'y' || normalized === 'yes';
173
+ resolve(confirmed);
174
+ });
175
+ });
176
+ }
177
+ /**
178
+ * Prompts user for access token with hidden input
179
+ */
180
+ async promptForToken() {
181
+ return new Promise((resolve, reject) => {
182
+ const rl = readline.createInterface({
183
+ input: process.stdin,
184
+ output: process.stdout,
185
+ });
186
+ process.stdout.write('Enter access token: ');
187
+ let token = '';
188
+ const { stdin } = process;
189
+ // Hide input by setting raw mode
190
+ if (stdin.isTTY) {
191
+ stdin.setRawMode(true);
192
+ }
193
+ const onData = (char) => {
194
+ const charStr = char.toString();
195
+ // Enter key
196
+ if (charStr === '\n' || charStr === '\r' || charStr === '\r\n') {
197
+ process.stdout.write('\n');
198
+ if (stdin.isTTY) {
199
+ stdin.setRawMode(false);
200
+ }
201
+ stdin.removeListener('data', onData);
202
+ rl.close();
203
+ resolve(token);
204
+ return;
205
+ }
206
+ // Ctrl+C
207
+ if (charStr === '\u0003') {
208
+ process.stdout.write('\n');
209
+ if (stdin.isTTY) {
210
+ stdin.setRawMode(false);
211
+ }
212
+ stdin.removeListener('data', onData);
213
+ rl.close();
214
+ reject(new Error('Cancelled by user'));
215
+ return;
216
+ }
217
+ // Backspace/Delete
218
+ if (charStr === '\u007F' || charStr === '\b') {
219
+ if (token.length > 0) {
220
+ token = token.slice(0, -1);
221
+ }
222
+ return;
223
+ }
224
+ // Printable characters only
225
+ if (charStr >= ' ') {
226
+ token += charStr;
227
+ }
228
+ };
229
+ stdin.on('data', onData);
230
+ });
231
+ }
232
+ }
@@ -0,0 +1,15 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ export default class AccountLogout extends ScCommand<typeof AccountLogout> {
3
+ static args: {};
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ 'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<{
12
+ count: number;
13
+ loggedOut: string[];
14
+ }>;
15
+ }
@@ -0,0 +1,113 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { checkbox, confirm } from '@inquirer/prompts';
3
+ import { Flags } from '@oclif/core';
4
+ export default class AccountLogout extends ScCommand {
5
+ static args = {};
6
+ static description = `Logout from authenticated organizations.
7
+
8
+ Removes locally stored organization credentials and access tokens.
9
+ Interactive mode allows selection with arrow keys and spacebar.`;
10
+ static examples = [
11
+ '<%= config.bin %> <%= command.id %>',
12
+ '<%= config.bin %> <%= command.id %> --org=my-org-id',
13
+ '<%= config.bin %> <%= command.id %> --org=production',
14
+ '<%= config.bin %> <%= command.id %> --all',
15
+ '<%= config.bin %> <%= command.id %> --org=my-org-id --no-prompt',
16
+ ];
17
+ static flags = {
18
+ 'all': Flags.boolean({
19
+ char: 'a',
20
+ default: false,
21
+ description: 'Logout of all organizations',
22
+ }),
23
+ 'no-prompt': Flags.boolean({
24
+ default: false,
25
+ description: 'Skip confirmation prompt and assume Yes',
26
+ }),
27
+ 'org': Flags.string({
28
+ char: 'o',
29
+ description: 'Organization ID or alias to logout from',
30
+ }),
31
+ };
32
+ async run() {
33
+ const { flags } = await this.parse(AccountLogout);
34
+ // Validate conflicting flags
35
+ if (flags.all && flags.org) {
36
+ this.error('Cannot specify both --all and --org flags', { exit: 2 });
37
+ }
38
+ // Get OrgManager instance
39
+ const orgManager = await this.getOrgManager();
40
+ // Get all authenticated organizations
41
+ const allOrgs = await orgManager.getAllOrgs();
42
+ // Handle case when no organizations exist
43
+ if (allOrgs.length === 0) {
44
+ this.log("No organizations found. Nothing to logout from.");
45
+ return { count: 0, loggedOut: [] };
46
+ }
47
+ // Determine which organizations to logout
48
+ let orgIdsToLogout = [];
49
+ if (flags.all) {
50
+ // Logout from all organizations
51
+ orgIdsToLogout = allOrgs.map((org) => org.orgId);
52
+ }
53
+ else if (flags.org) {
54
+ // Logout from specific organization
55
+ const org = allOrgs.find((o) => o.orgId === flags.org || o.alias === flags.org);
56
+ if (!org) {
57
+ this.error(`Organization '${flags.org}' not found. Run 'sc account:list' to see available organizations.`, { exit: 2 });
58
+ }
59
+ orgIdsToLogout = [org.orgId];
60
+ }
61
+ else {
62
+ // Interactive mode: let user select organizations
63
+ try {
64
+ orgIdsToLogout = await checkbox({
65
+ choices: allOrgs.map((org) => ({
66
+ name: org.alias ? `${org.orgId} (${org.alias})` : org.orgId,
67
+ value: org.orgId,
68
+ })),
69
+ message: 'Select organizations to logout from:',
70
+ required: true,
71
+ });
72
+ }
73
+ catch {
74
+ // User cancelled the selection (Ctrl+C)
75
+ this.log('Logout cancelled.');
76
+ return { count: 0, loggedOut: [] };
77
+ }
78
+ }
79
+ // Confirm logout unless --no-prompt flag is set
80
+ if (!flags['no-prompt']) {
81
+ const count = orgIdsToLogout.length;
82
+ const orgWord = count === 1 ? 'organization' : 'organizations';
83
+ try {
84
+ const shouldProceed = await confirm({
85
+ default: true,
86
+ message: `Are you sure you want to logout from ${count} ${orgWord}?`,
87
+ });
88
+ if (!shouldProceed) {
89
+ this.log('Logout cancelled.');
90
+ return { count: 0, loggedOut: [] };
91
+ }
92
+ }
93
+ catch {
94
+ // User cancelled the confirmation (Ctrl+C)
95
+ this.log('Logout cancelled.');
96
+ return { count: 0, loggedOut: [] };
97
+ }
98
+ }
99
+ // Logout from selected organizations (remove all in parallel)
100
+ await Promise.all(orgIdsToLogout.map((orgId) => orgManager.removeOrg(orgId)));
101
+ // Display success messages
102
+ for (const orgId of orgIdsToLogout) {
103
+ const org = allOrgs.find((o) => o.orgId === orgId);
104
+ const displayName = org?.alias ? `${orgId} (${org.alias})` : orgId;
105
+ this.log(`Successfully logged out from: ${displayName}`);
106
+ }
107
+ // Return result for --json support
108
+ return {
109
+ count: orgIdsToLogout.length,
110
+ loggedOut: orgIdsToLogout,
111
+ };
112
+ }
113
+ }
@@ -11,6 +11,7 @@ export default class MissionctrlBrokerCreate extends ScCommand<typeof Missionctr
11
11
  'max-spool-usage': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
12
  'msg-vpn-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
13
  name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
15
  'redundancy-group-ssl-enabled': import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
16
  'service-class-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
16
17
  version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -1,5 +1,6 @@
1
- import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
+ import { printObjectAsKeyValueTable, ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { Flags } from '@oclif/core';
3
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
3
4
  export default class MissionctrlBrokerCreate extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Create an event broker service. You must provide a unique name and select a service class and datacenter. You can optionally define other properties for the event broker service.
@@ -9,6 +10,7 @@ Your token must have one of the permissions listed in the Token Permissions.
9
10
  Token Permissions: [ \`services:post\` ]`;
10
11
  static examples = [
11
12
  '<%= config.bin %> <%= command.id %> --name=MyBrokerName --datacenter-id=eks-ca-central-1a --service-class-id=DEVELOPER',
13
+ '<%= config.bin %> <%= command.id %> --org=my-org --name=MyBrokerName --datacenter-id=eks-ca-central-1a --service-class-id=DEVELOPER',
12
14
  ];
13
15
  static flags = {
14
16
  'datacenter-id': Flags.string({
@@ -41,6 +43,10 @@ Token Permissions: [ \`services:post\` ]`;
41
43
  description: 'Name of the event broker service to create.',
42
44
  required: true,
43
45
  }),
46
+ org: Flags.string({
47
+ char: 'o',
48
+ description: 'Organization ID or alias to use. If not specified, uses the default organization.',
49
+ }),
44
50
  'redundancy-group-ssl-enabled': Flags.boolean({
45
51
  char: 'r',
46
52
  default: false,
@@ -68,7 +74,7 @@ Token Permissions: [ \`services:post\` ]`;
68
74
  const serviceClassId = flags['service-class-id'] ?? 'DEVELOPER';
69
75
  const eventBrokerVersion = flags.version ?? '';
70
76
  let envId = '';
71
- const conn = new ScConnection();
77
+ const conn = await resolveOrgConnection(this, flags.org);
72
78
  // API url
73
79
  const apiUrl = `/missionControl/eventBrokerServices`;
74
80
  // If envName is provided, retrieve the environment ID
@@ -7,6 +7,7 @@ export default class MissionctrlBrokerDelete extends ScCommand<typeof Missionctr
7
7
  static flags: {
8
8
  'broker-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
9
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
11
  };
11
12
  run(): Promise<EventBrokerOperationApiResponse>;
12
13
  }
@@ -1,5 +1,6 @@
1
- import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
+ import { printObjectAsKeyValueTable, ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { Flags } from '@oclif/core';
3
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
3
4
  export default class MissionctrlBrokerDelete extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Delete a service using its unique identifier.
@@ -10,6 +11,7 @@ Token Permissions: [ \`services:delete\` **or** \`services:delete:self\` **or**
10
11
  static examples = [
11
12
  '<%= config.bin %> <%= command.id %> --broker-id=MyBrokerId',
12
13
  '<%= config.bin %> <%= command.id %> --name=MyBrokerName',
14
+ '<%= config.bin %> <%= command.id %> --org=my-org --broker-id=MyBrokerId',
13
15
  ];
14
16
  static flags = {
15
17
  'broker-id': Flags.string({
@@ -22,12 +24,16 @@ Token Permissions: [ \`services:delete\` **or** \`services:delete:self\` **or**
22
24
  description: 'Name of the event broker service.',
23
25
  exactlyOne: ['broker-id', 'name'],
24
26
  }),
27
+ org: Flags.string({
28
+ char: 'o',
29
+ description: 'Organization ID or alias to use. If not specified, uses the default organization.',
30
+ }),
25
31
  };
26
32
  async run() {
27
33
  const { flags } = await this.parse(MissionctrlBrokerDelete);
28
34
  const name = flags.name ?? '';
29
35
  const brokerId = flags['broker-id'] ?? '';
30
- const conn = new ScConnection();
36
+ const conn = await resolveOrgConnection(this, flags.org);
31
37
  // API url
32
38
  let apiUrl = `/missionControl/eventBrokerServices`;
33
39
  let brokerIdToDelete = brokerId;
@@ -7,6 +7,7 @@ export default class MissionctrlBrokerDisplay extends ScCommand<typeof Missionct
7
7
  static flags: {
8
8
  'broker-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
9
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
11
  };
11
12
  run(): Promise<EventBrokerApiResponse | EventBrokerListApiResponse>;
12
13
  }
@@ -1,5 +1,6 @@
1
- import { printObjectAsKeyValueTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
+ import { printObjectAsKeyValueTable, ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { Flags } from '@oclif/core';
3
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
3
4
  export default class MissionctrlBrokerDisplay extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Get the details of an event broker service using its identifier or name.
@@ -7,7 +8,10 @@ export default class MissionctrlBrokerDisplay extends ScCommand {
7
8
  Use either the Event Broker's ID (--broker-id) or name of the Event Broker (--name).
8
9
 
9
10
  Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \`services:get:self\` **or** \`services:view\` **or** \`services:view:self\` ]`;
10
- static examples = ['<%= config.bin %> <%= command.id %>'];
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %> --broker-id=MyBrokerId',
13
+ '<%= config.bin %> <%= command.id %> --org=my-org --name=MyBrokerName',
14
+ ];
11
15
  static flags = {
12
16
  'broker-id': Flags.string({
13
17
  char: 'b',
@@ -19,12 +23,16 @@ export default class MissionctrlBrokerDisplay extends ScCommand {
19
23
  description: 'Name of the event broker service.',
20
24
  exactlyOne: ['broker-id', 'name'],
21
25
  }),
26
+ org: Flags.string({
27
+ char: 'o',
28
+ description: 'Organization ID or alias to use. If not specified, uses the default organization.',
29
+ }),
22
30
  };
23
31
  async run() {
24
32
  const { flags } = await this.parse(MissionctrlBrokerDisplay);
25
33
  const name = flags.name ?? '';
26
34
  const brokerId = flags['broker-id'] ?? '';
27
- const conn = new ScConnection();
35
+ const conn = await resolveOrgConnection(this, flags.org);
28
36
  // API url
29
37
  let apiUrl = `/missionControl/eventBrokerServices`;
30
38
  // If broker name provided, get all brokers matching provided name
@@ -6,6 +6,7 @@ export default class MissionctrlBrokerList extends ScCommand<typeof MissionctrlB
6
6
  static examples: string[];
7
7
  static flags: {
8
8
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  pageNumber: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
11
  pageSize: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
12
  sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -1,5 +1,6 @@
1
- import { renderTable, ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
+ import { renderTable, ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { Flags } from '@oclif/core';
3
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
3
4
  export default class MissionctrlBrokerList extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Get a listing of event broker services.
@@ -9,6 +10,7 @@ Your token must have one of the permissions listed in the Token Permissions.
9
10
  Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \`services:get:self\` **or** \`services:view\` **or** \`services:view:self\` ]`;
10
11
  static examples = [
11
12
  '<%= config.bin %> <%= command.id %>',
13
+ '<%= config.bin %> <%= command.id %> --org=my-org',
12
14
  '<%= config.bin %> <%= command.id %> --name=MyBrokerName --pageNumber=1 --pageSize=10 --sort=name:asc',
13
15
  ];
14
16
  static flags = {
@@ -16,6 +18,10 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
16
18
  char: 'n',
17
19
  description: 'Name of the event broker service to match on.',
18
20
  }),
21
+ org: Flags.string({
22
+ char: 'o',
23
+ description: 'Organization ID or alias to use. If not specified, uses the default organization.',
24
+ }),
19
25
  pageNumber: Flags.integer({
20
26
  description: 'The page number to get. Defaults to 1',
21
27
  }),
@@ -35,7 +41,7 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
35
41
  };
36
42
  async run() {
37
43
  const { flags } = await this.parse(MissionctrlBrokerList);
38
- const conn = new ScConnection();
44
+ const conn = await resolveOrgConnection(this, flags.org);
39
45
  const pageSize = flags.pageSize ?? 10;
40
46
  const pageNumber = flags.pageNumber ?? 1;
41
47
  // API url
@@ -7,6 +7,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
7
7
  static flags: {
8
8
  'broker-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
9
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
11
  'show-progress': import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
12
  'wait-ms': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
13
  };