@dishantlangayan/solace-cloud-cli 0.2.1 → 0.4.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 +214 -145
  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 +231 -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 +2 -0
  9. package/dist/commands/missionctrl/broker/create.js +15 -2
  10. package/dist/commands/missionctrl/broker/delete.d.ts +2 -0
  11. package/dist/commands/missionctrl/broker/delete.js +15 -2
  12. package/dist/commands/missionctrl/broker/display.d.ts +2 -0
  13. package/dist/commands/missionctrl/broker/display.js +18 -3
  14. package/dist/commands/missionctrl/broker/list.d.ts +2 -0
  15. package/dist/commands/missionctrl/broker/list.js +15 -5
  16. package/dist/commands/missionctrl/broker/opstatus.d.ts +2 -0
  17. package/dist/commands/missionctrl/broker/opstatus.js +15 -2
  18. package/dist/commands/missionctrl/broker/state.d.ts +2 -0
  19. package/dist/commands/missionctrl/broker/state.js +15 -2
  20. package/dist/commands/missionctrl/broker/update.d.ts +2 -0
  21. package/dist/commands/missionctrl/broker/update.js +15 -3
  22. package/dist/commands/platform/env/create.d.ts +2 -0
  23. package/dist/commands/platform/env/create.js +16 -3
  24. package/dist/commands/platform/env/delete.d.ts +2 -0
  25. package/dist/commands/platform/env/delete.js +15 -2
  26. package/dist/commands/platform/env/display.d.ts +2 -0
  27. package/dist/commands/platform/env/display.js +15 -2
  28. package/dist/commands/platform/env/list.d.ts +2 -0
  29. package/dist/commands/platform/env/list.js +15 -3
  30. package/dist/commands/platform/env/update.d.ts +2 -0
  31. package/dist/commands/platform/env/update.js +16 -3
  32. package/dist/lib/org-utils.d.ts +24 -0
  33. package/dist/lib/org-utils.js +73 -0
  34. package/oclif.manifest.json +727 -224
  35. package/package.json +3 -3
  36. package/dist/config/env-vars.d.ts +0 -44
  37. package/dist/config/env-vars.js +0 -47
@@ -1,23 +1,33 @@
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.
6
7
 
7
- The maximum number of objects that can be returned in a single page is 100. Default is 10.
8
-
9
8
  Your token must have one of the permissions listed in the Token Permissions.
10
9
 
11
10
  Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \`services:get:self\` **or** \`services:view\` **or** \`services:view:self\` ]`;
12
11
  static examples = [
13
12
  '<%= config.bin %> <%= command.id %>',
14
- '<%= config.bin %> <%= command.id %> --name=MyBrokerName --pageNumber=1 --pageSize=10 --sort=name:asc',
13
+ '<%= config.bin %> <%= command.id %> --org=my-org',
14
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=MyBrokerName --pageNumber=1 --pageSize=10 --sort=name:asc',
15
15
  ];
16
16
  static flags = {
17
+ alias: Flags.string({
18
+ char: 'a',
19
+ description: 'Organization alias to use. If not specified, uses the default organization.',
20
+ exclusive: ['org'],
21
+ }),
17
22
  name: Flags.string({
18
23
  char: 'n',
19
24
  description: 'Name of the event broker service to match on.',
20
25
  }),
26
+ org: Flags.string({
27
+ char: 'o',
28
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
29
+ exclusive: ['alias'],
30
+ }),
21
31
  pageNumber: Flags.integer({
22
32
  description: 'The page number to get. Defaults to 1',
23
33
  }),
@@ -37,7 +47,7 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
37
47
  };
38
48
  async run() {
39
49
  const { flags } = await this.parse(MissionctrlBrokerList);
40
- const conn = new ScConnection();
50
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
41
51
  const pageSize = flags.pageSize ?? 10;
42
52
  const pageNumber = flags.pageNumber ?? 1;
43
53
  // API url
@@ -5,8 +5,10 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
9
  'broker-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
12
  'show-progress': import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
13
  'wait-ms': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
14
  };
@@ -1,6 +1,7 @@
1
- import { renderTable, ScCommand, ScConnection, sleep } from '@dishantlangayan/sc-cli-core';
1
+ import { renderTable, ScCommand, sleep } from '@dishantlangayan/sc-cli-core';
2
2
  import { Flags } from '@oclif/core';
3
3
  import { MultiBar, Presets } from 'cli-progress';
4
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
4
5
  export default class MissionctrlBrokerOpstatus extends ScCommand {
5
6
  static args = {};
6
7
  static description = `Get the status of all operations being performed on an event broker service.
@@ -10,8 +11,15 @@ export default class MissionctrlBrokerOpstatus extends ScCommand {
10
11
  static examples = [
11
12
  '<%= config.bin %> <%= command.id %> -b <broker-id>',
12
13
  '<%= config.bin %> <%= command.id %> -n <broker-name>',
14
+ '<%= config.bin %> <%= command.id %> --org=my-org -b <broker-id>',
15
+ '<%= config.bin %> <%= command.id %> --alias=my-alias -b <broker-id>',
13
16
  ];
14
17
  static flags = {
18
+ alias: Flags.string({
19
+ char: 'a',
20
+ description: 'Organization alias to use. If not specified, uses the default organization.',
21
+ exclusive: ['org'],
22
+ }),
15
23
  'broker-id': Flags.string({
16
24
  char: 'b',
17
25
  description: 'Id of the event broker service.',
@@ -22,6 +30,11 @@ export default class MissionctrlBrokerOpstatus extends ScCommand {
22
30
  description: 'Name of the event broker service.',
23
31
  exactlyOne: ['broker-id', 'name'],
24
32
  }),
33
+ org: Flags.string({
34
+ char: 'o',
35
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
36
+ exclusive: ['alias'],
37
+ }),
25
38
  'show-progress': Flags.boolean({
26
39
  char: 'p',
27
40
  description: 'Displays a status bar of the in-progress operations. The command will wait for completion of each step of the operation.',
@@ -37,7 +50,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand {
37
50
  let brokerId = flags['broker-id'] ?? '';
38
51
  const showProgress = flags['show-progress'] ?? false;
39
52
  const waitMs = flags['wait-ms'] ?? 5000;
40
- const conn = new ScConnection();
53
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
41
54
  // Base API url
42
55
  let apiUrl = `/missionControl/eventBrokerServices`;
43
56
  // If broker name provided, retrieve the broker service id first
@@ -5,8 +5,10 @@ export default class MissionctrlBrokerState extends ScCommand<typeof Missionctrl
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
9
  'broker-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
12
  };
11
13
  run(): Promise<EventBrokerRedundancyApiResponse>;
12
14
  }
@@ -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 MissionctrlBrokerState extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Get the availability state of an event broker service and the name of the active messaging node using the service's unique identifier.
@@ -10,8 +11,15 @@ export default class MissionctrlBrokerState extends ScCommand {
10
11
  static examples = [
11
12
  '<%= config.bin %> <%= command.id %> --broker-id=MyBrokerServiceId',
12
13
  '<%= config.bin %> <%= command.id %> --name=MyBrokerName',
14
+ '<%= config.bin %> <%= command.id %> --org=my-org --broker-id=MyBrokerServiceId',
15
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=MyBrokerName',
13
16
  ];
14
17
  static flags = {
18
+ alias: Flags.string({
19
+ char: 'a',
20
+ description: 'Organization alias to use. If not specified, uses the default organization.',
21
+ exclusive: ['org'],
22
+ }),
15
23
  'broker-id': Flags.string({
16
24
  char: 'b',
17
25
  description: 'Id of the event broker service.',
@@ -22,12 +30,17 @@ export default class MissionctrlBrokerState extends ScCommand {
22
30
  description: 'Name of the event broker service.',
23
31
  exactlyOne: ['broker-id', 'name'],
24
32
  }),
33
+ org: Flags.string({
34
+ char: 'o',
35
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
36
+ exclusive: ['alias'],
37
+ }),
25
38
  };
26
39
  async run() {
27
40
  const { flags } = await this.parse(MissionctrlBrokerState);
28
41
  const name = flags.name ?? '';
29
42
  let brokerId = flags['broker-id'] ?? '';
30
- const conn = new ScConnection();
43
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
31
44
  // API url
32
45
  let apiUrl = `/missionControl/eventBrokerServices`;
33
46
  if (name) {
@@ -5,10 +5,12 @@ export default class MissionctrlBrokerUpdate extends ScCommand<typeof Missionctr
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
9
  'broker-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  locked: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
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>;
13
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
14
  };
13
15
  run(): Promise<EventBrokerOperationApiResponse>;
14
16
  }
@@ -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 MissionctrlBrokerUpdate extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Update the configuration of an existing event broker service.
@@ -11,9 +12,15 @@ export default class MissionctrlBrokerUpdate extends ScCommand {
11
12
  static examples = [
12
13
  '<%= config.bin %> <%= command.id %>',
13
14
  '<%= config.bin %> <%= command.id %> --broker-id <broker-id> --new-name <new-name>',
14
- '<%= config.bin %> <%= command.id %> --name <name> --new-name <new-name>',
15
+ '<%= config.bin %> <%= command.id %> --org=my-org --name <name> --new-name <new-name>',
16
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name <name> --new-name <new-name>',
15
17
  ];
16
18
  static flags = {
19
+ alias: Flags.string({
20
+ char: 'a',
21
+ description: 'Organization alias to use. If not specified, uses the default organization.',
22
+ exclusive: ['org'],
23
+ }),
17
24
  'broker-id': Flags.string({
18
25
  char: 'b',
19
26
  description: 'Id of the event broker service.',
@@ -31,6 +38,11 @@ export default class MissionctrlBrokerUpdate extends ScCommand {
31
38
  'new-name': Flags.string({
32
39
  description: 'New name of the event broker service. The new service name must be unique within an organization.',
33
40
  }),
41
+ org: Flags.string({
42
+ char: 'o',
43
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
44
+ exclusive: ['alias'],
45
+ }),
34
46
  };
35
47
  async run() {
36
48
  const { flags } = await this.parse(MissionctrlBrokerUpdate);
@@ -44,7 +56,7 @@ export default class MissionctrlBrokerUpdate extends ScCommand {
44
56
  ...(locked && { locked: lockedBoolValue }),
45
57
  ...(newName && { name: newName }),
46
58
  };
47
- const conn = new ScConnection();
59
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
48
60
  // API url
49
61
  let apiUrl = `/missionControl/eventBrokerServices`;
50
62
  let brokerIdToUpdate = brokerId;
@@ -5,10 +5,12 @@ export default class PlatformEnvCreate extends ScCommand<typeof PlatformEnvCreat
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
9
  description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  isDefault: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
11
  isProduction: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
12
  name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
14
  };
13
15
  run(): Promise<EnvironmentApiResponse>;
14
16
  }
@@ -1,14 +1,22 @@
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 PlatformEnvCreate extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Create a new environment.
6
7
 
7
8
  Token Permissions: [ environments:edit ]`;
8
9
  static examples = [
9
- '<%= config.bin %> <%= command.id %> --name=MyEnvironment --description="My environment description" --isDefault --isProduction',
10
+ '<%= config.bin %> <%= command.id %> --name=MyEnvironment',
11
+ '<%= config.bin %> <%= command.id %> --org=my-org --name=MyEnvironment --description="My environment description" --isDefault --isProduction',
12
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=MyEnvironment --isDefault',
10
13
  ];
11
14
  static flags = {
15
+ alias: Flags.string({
16
+ char: 'a',
17
+ description: 'Organization alias to use. If not specified, uses the default organization.',
18
+ exclusive: ['org'],
19
+ }),
12
20
  description: Flags.string({
13
21
  char: 'd',
14
22
  description: 'Description of the environment to create.',
@@ -27,6 +35,11 @@ export default class PlatformEnvCreate extends ScCommand {
27
35
  description: 'Name of the environment to create.',
28
36
  required: true,
29
37
  }),
38
+ org: Flags.string({
39
+ char: 'o',
40
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
41
+ exclusive: ['alias'],
42
+ }),
30
43
  };
31
44
  async run() {
32
45
  const { flags } = await this.parse(PlatformEnvCreate);
@@ -34,7 +47,7 @@ export default class PlatformEnvCreate extends ScCommand {
34
47
  const desc = flags.description ?? '';
35
48
  const isDefault = flags.isDefault ?? false;
36
49
  const isProduction = flags.isProduction ?? false;
37
- const conn = new ScConnection();
50
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
38
51
  // API url
39
52
  const apiUrl = `/platform/environments`;
40
53
  // API body
@@ -4,8 +4,10 @@ export default class PlatformEnvDelete extends ScCommand<typeof PlatformEnvDelet
4
4
  static description: string;
5
5
  static examples: string[];
6
6
  static flags: {
7
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
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>;
10
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
11
  };
10
12
  run(): Promise<{
11
13
  message: string;
@@ -1,5 +1,6 @@
1
- import { ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
1
+ import { 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 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.
@@ -8,8 +9,15 @@ export default class PlatformEnvDelete extends ScCommand {
8
9
  static examples = [
9
10
  '<%= config.bin %> <%= command.id %> --name=MyEnvName',
10
11
  '<%= config.bin %> <%= command.id %> --env-id=MyEnvId',
12
+ '<%= config.bin %> <%= command.id %> --org=my-org --name=MyEnvName',
13
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=MyEnvName',
11
14
  ];
12
15
  static flags = {
16
+ alias: Flags.string({
17
+ char: 'a',
18
+ description: 'Organization alias to use. If not specified, uses the default organization.',
19
+ exclusive: ['org'],
20
+ }),
13
21
  'env-id': Flags.string({
14
22
  char: 'e',
15
23
  description: 'Id of the environment.',
@@ -20,12 +28,17 @@ export default class PlatformEnvDelete extends ScCommand {
20
28
  description: 'Name of the environment.',
21
29
  exactlyOne: ['env-id', 'name'],
22
30
  }),
31
+ org: Flags.string({
32
+ char: 'o',
33
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
34
+ exclusive: ['alias'],
35
+ }),
23
36
  };
24
37
  async run() {
25
38
  const { flags } = await this.parse(PlatformEnvDelete);
26
39
  const name = flags.name ?? '';
27
40
  const envId = flags['env-id'] ?? '';
28
- const conn = new ScConnection();
41
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
29
42
  // API url
30
43
  let apiUrl = `/platform/environments`;
31
44
  let envIdToDelete = envId;
@@ -5,8 +5,10 @@ export default class PlatformEnvDisplay extends ScCommand<typeof PlatformEnvDisp
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
9
  'env-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
12
  };
11
13
  run(): Promise<EnvironmentApiResponse | EnvironmentListApiResponse>;
12
14
  }
@@ -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 PlatformEnvDisplay extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Display information about an Environment.
@@ -10,8 +11,15 @@ export default class PlatformEnvDisplay extends ScCommand {
10
11
  static examples = [
11
12
  '<%= config.bin %> <%= command.id %> --name=MyEnvName',
12
13
  '<%= config.bin %> <%= command.id %> --env-id=MyEnvId',
14
+ '<%= config.bin %> <%= command.id %> --org=my-org --env-id=MyEnvId',
15
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=MyEnvName',
13
16
  ];
14
17
  static flags = {
18
+ alias: Flags.string({
19
+ char: 'a',
20
+ description: 'Organization alias to use. If not specified, uses the default organization.',
21
+ exclusive: ['org'],
22
+ }),
15
23
  'env-id': Flags.string({
16
24
  char: 'e',
17
25
  description: 'Id of the environment.',
@@ -22,12 +30,17 @@ export default class PlatformEnvDisplay extends ScCommand {
22
30
  description: 'Name of the environment.',
23
31
  exactlyOne: ['env-id', 'name'],
24
32
  }),
33
+ org: Flags.string({
34
+ char: 'o',
35
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
36
+ exclusive: ['alias'],
37
+ }),
25
38
  };
26
39
  async run() {
27
40
  const { flags } = await this.parse(PlatformEnvDisplay);
28
41
  const name = flags.name ?? '';
29
42
  const envId = flags['env-id'] ?? '';
30
- const conn = new ScConnection();
43
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
31
44
  // API url
32
45
  // If env name provided, get all environments matching provided name
33
46
  // If env id provided, get environment with that id
@@ -5,7 +5,9 @@ export default class PlatformEnvList extends ScCommand<typeof PlatformEnvList> {
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ alias: 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>;
10
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
11
  pageNumber: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
12
  pageSize: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
13
  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 PlatformEnvList extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Get a list of all Environments.
@@ -7,13 +8,24 @@ export default class PlatformEnvList extends ScCommand {
7
8
  Required token permissions: [ environments:view ]`;
8
9
  static examples = [
9
10
  '<%= config.bin %> <%= command.id %>',
10
- '<%= config.bin %> <%= command.id %> --name=Default --pageNumber=1 --pageSize=10 --sort=name:ASC',
11
+ '<%= config.bin %> <%= command.id %> --org=my-org',
12
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=Default --pageNumber=1 --pageSize=10 --sort=name:ASC',
11
13
  ];
12
14
  static flags = {
15
+ alias: Flags.string({
16
+ char: 'a',
17
+ description: 'Organization alias to use. If not specified, uses the default organization.',
18
+ exclusive: ['org'],
19
+ }),
13
20
  name: Flags.string({
14
21
  char: 'n',
15
22
  description: 'Name of the environment to match on.',
16
23
  }),
24
+ org: Flags.string({
25
+ char: 'o',
26
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
27
+ exclusive: ['alias'],
28
+ }),
17
29
  pageNumber: Flags.integer({
18
30
  char: 'p',
19
31
  description: 'The page number to get. Defaults to 10',
@@ -30,7 +42,7 @@ export default class PlatformEnvList extends ScCommand {
30
42
  };
31
43
  async run() {
32
44
  const { flags } = await this.parse(PlatformEnvList);
33
- const conn = new ScConnection();
45
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
34
46
  const pageSize = flags.pageSize ?? 10;
35
47
  const pageNumber = flags.pageNumber ?? 1;
36
48
  // API url
@@ -5,11 +5,13 @@ export default class PlatformEnvUpdate extends ScCommand<typeof PlatformEnvUpdat
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
9
  description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  'env-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
11
  isDefault: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
12
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
13
  'new-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
15
  };
14
16
  run(): Promise<EnvironmentApiResponse>;
15
17
  }
@@ -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 PlatformEnvUpdate extends ScCommand {
4
5
  static args = {};
5
6
  static description = `Modify an environment's attributes
@@ -9,10 +10,17 @@ export default class PlatformEnvUpdate extends ScCommand {
9
10
  Token Permissions: [ environments:edit ]
10
11
  `;
11
12
  static examples = [
12
- '<%= config.bin %> <%= command.id %> --name=MyEnvName --new-name=MyNewEnvName --description="My description to update" --isDefault',
13
+ '<%= config.bin %> <%= command.id %> --name=MyEnvName --new-name=MyNewEnvName',
13
14
  '<%= config.bin %> <%= command.id %> --env-id=MyEnvId --new-name=MyNewEnvName --description="My description to update" --isDefault',
15
+ '<%= config.bin %> <%= command.id %> --org=my-org --name=MyEnvName --isDefault',
16
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=MyEnvName --new-name=MyNewEnvName',
14
17
  ];
15
18
  static flags = {
19
+ alias: Flags.string({
20
+ char: 'a',
21
+ description: 'Organization alias to use. If not specified, uses the default organization.',
22
+ exclusive: ['org'],
23
+ }),
16
24
  description: Flags.string({
17
25
  char: 'd',
18
26
  description: 'Description of the environment to update.',
@@ -33,6 +41,11 @@ export default class PlatformEnvUpdate extends ScCommand {
33
41
  'new-name': Flags.string({
34
42
  description: 'New name of the environment.',
35
43
  }),
44
+ org: Flags.string({
45
+ char: 'o',
46
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
47
+ exclusive: ['alias'],
48
+ }),
36
49
  };
37
50
  async run() {
38
51
  const { flags } = await this.parse(PlatformEnvUpdate);
@@ -46,7 +59,7 @@ export default class PlatformEnvUpdate extends ScCommand {
46
59
  ...(desc && { description: desc }),
47
60
  ...(newName && { name: newName }),
48
61
  };
49
- const conn = new ScConnection();
62
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
50
63
  // API url
51
64
  let apiUrl = `/platform/environments`;
52
65
  let envIdToUpdate = envId;
@@ -0,0 +1,24 @@
1
+ import { ScCommand, ScConnection } from '@dishantlangayan/sc-cli-core';
2
+ import { Command } from '@oclif/core';
3
+ /**
4
+ * Resolves organization and creates authenticated ScConnection
5
+ *
6
+ * This utility function handles the common pattern of resolving which organization
7
+ * to use for API calls. It supports both explicit org specification via the --org flag
8
+ * and automatic default org resolution.
9
+ *
10
+ * @param command - The ScCommand instance (for error handling and OrgManager access)
11
+ * @param orgIdentifier - Optional org ID or alias from --org flag
12
+ * @param timeout - Optional timeout override in milliseconds (default: 10000ms)
13
+ * @returns Configured ScConnection instance ready for API calls
14
+ * @throws Will call command.error() with user-friendly messages for various error scenarios
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // In a command's run() method:
19
+ * const {flags} = await this.parse(MyCommand)
20
+ * const conn = await resolveOrgConnection(this, flags.org)
21
+ * const resp = await conn.get('/api/endpoint')
22
+ * ```
23
+ */
24
+ export declare function resolveOrgConnection(command: ScCommand<typeof Command>, orgIdentifier?: string, timeout?: number): Promise<ScConnection>;
@@ -0,0 +1,73 @@
1
+ import { OrgError, OrgErrorCode } from '@dishantlangayan/sc-cli-core';
2
+ /**
3
+ * Resolves organization and creates authenticated ScConnection
4
+ *
5
+ * This utility function handles the common pattern of resolving which organization
6
+ * to use for API calls. It supports both explicit org specification via the --org flag
7
+ * and automatic default org resolution.
8
+ *
9
+ * @param command - The ScCommand instance (for error handling and OrgManager access)
10
+ * @param orgIdentifier - Optional org ID or alias from --org flag
11
+ * @param timeout - Optional timeout override in milliseconds (default: 10000ms)
12
+ * @returns Configured ScConnection instance ready for API calls
13
+ * @throws Will call command.error() with user-friendly messages for various error scenarios
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // In a command's run() method:
18
+ * const {flags} = await this.parse(MyCommand)
19
+ * const conn = await resolveOrgConnection(this, flags.org)
20
+ * const resp = await conn.get('/api/endpoint')
21
+ * ```
22
+ */
23
+ export async function resolveOrgConnection(command, orgIdentifier, timeout) {
24
+ try {
25
+ // Use type assertion to access protected method
26
+ const orgManager = await command.getOrgManager();
27
+ // If org identifier provided, validate and use it
28
+ if (orgIdentifier) {
29
+ const org = await orgManager.getOrg(orgIdentifier);
30
+ if (!org) {
31
+ command.error(`Organization '${orgIdentifier}' not found. Run 'sc account:list' to see available organizations.`, { exit: 2 });
32
+ }
33
+ return await orgManager.createConnection(orgIdentifier, timeout);
34
+ }
35
+ // No org specified, try default
36
+ const defaultOrg = await orgManager.getDefaultOrg();
37
+ if (!defaultOrg) {
38
+ const allOrgs = await orgManager.getAllOrgs();
39
+ if (allOrgs.length === 0) {
40
+ command.error("No organizations found. Please run 'sc account:login' to authenticate.", { exit: 2 });
41
+ }
42
+ else {
43
+ command.error("No default organization set. Please specify --org flag or set a default with 'sc account:login --set-default'.", { exit: 2 });
44
+ }
45
+ }
46
+ return await orgManager.createConnection(defaultOrg.orgId, timeout);
47
+ }
48
+ catch (error) {
49
+ // Handle OrgManager-specific errors
50
+ if (error instanceof OrgError) {
51
+ switch (error.code) {
52
+ case OrgErrorCode.INVALID_ACCESS_TOKEN: {
53
+ command.error("Invalid access token. Please re-authenticate with 'sc account:login'.", { exit: 2 });
54
+ break;
55
+ }
56
+ case OrgErrorCode.NOT_INITIALIZED: {
57
+ command.error("Organization manager not initialized. Please run 'sc account:login' to authenticate.", { exit: 2 });
58
+ break;
59
+ }
60
+ case OrgErrorCode.ORG_NOT_FOUND: {
61
+ command.error("Organization not found. Run 'sc account:list' to see available organizations.", { exit: 2 });
62
+ break;
63
+ }
64
+ default: {
65
+ command.error(`Organization error: ${error.message}`, { exit: 2 });
66
+ break;
67
+ }
68
+ }
69
+ }
70
+ // Re-throw unexpected errors
71
+ throw error;
72
+ }
73
+ }