@dishantlangayan/solace-cloud-cli 0.7.0 → 0.9.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.
@@ -5,12 +5,13 @@ export default class MissionctrlBrokerList extends ScCommand<typeof MissionctrlB
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ 'page-number': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
12
  alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
13
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
14
  org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- pageNumber: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- pageSize: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
15
  };
15
16
  run(): Promise<EventBrokerListApiResponse>;
16
17
  }
@@ -1,6 +1,7 @@
1
- import { renderTable, ScCommand } from '@dishantlangayan/sc-cli-core';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { Flags } from '@oclif/core';
3
3
  import { resolveOrgConnection } from '../../../lib/org-utils.js';
4
+ import { createTableWriter, DEFAULT_PAGE_SIZE, fetchPages, MAX_PAGE_SIZE, paginationFlags, } from '../../../lib/pagination.js';
4
5
  export default class MissionctrlBrokerList extends ScCommand {
5
6
  static args = {};
6
7
  static description = `Get a listing of event broker services.
@@ -11,7 +12,8 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
11
12
  static examples = [
12
13
  '<%= config.bin %> <%= command.id %>',
13
14
  '<%= 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
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=MyBrokerName --page-number=1 --page-size=10 --sort=name:asc',
16
+ '<%= config.bin %> <%= command.id %> --all',
15
17
  ];
16
18
  static flags = {
17
19
  alias: Flags.string({
@@ -28,14 +30,7 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
28
30
  description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
29
31
  exclusive: ['alias'],
30
32
  }),
31
- pageNumber: Flags.integer({
32
- description: 'The page number to get. Defaults to 1',
33
- }),
34
- pageSize: Flags.integer({
35
- description: 'The number of event broker services to return per page. Defaults to 10',
36
- max: 100,
37
- min: 1,
38
- }),
33
+ ...paginationFlags('event broker services'),
39
34
  sort: Flags.string({
40
35
  description: `Sort the returned event broker services by attribute.
41
36
 
@@ -48,22 +43,44 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
48
43
  async run() {
49
44
  const { flags } = await this.parse(MissionctrlBrokerList);
50
45
  const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
51
- const pageSize = flags.pageSize ?? 10;
52
- const pageNumber = flags.pageNumber ?? 1;
46
+ const pageSize = flags['page-size'] ?? (flags.all ? MAX_PAGE_SIZE : DEFAULT_PAGE_SIZE);
47
+ const pageNumber = flags['page-number'] ?? 1;
53
48
  // API url
54
- let apiUrl = `/missionControl/eventBrokerServices?pageSize=${pageSize}&pageNumber=${pageNumber}`;
55
- if (flags.sort) {
56
- apiUrl += `&sort=${flags.sort}`;
57
- }
58
- if (flags.name) {
59
- apiUrl += `&customAttributes=name=="${flags.name}"`;
60
- }
61
- // API call
62
- const resp = await conn.get(apiUrl);
63
- // Array to output as table
64
- const brokerArray = [
65
- ['Name', 'Id', 'Type', 'Version', 'Owned By', 'Datacenter Id', 'Service Class Id'],
66
- ...resp.data.map((item) => [
49
+ const buildUrl = (page, size) => {
50
+ let apiUrl = `/missionControl/eventBrokerServices?pageSize=${size}&pageNumber=${page}`;
51
+ if (flags.sort) {
52
+ apiUrl += `&sort=${flags.sort}`;
53
+ }
54
+ if (flags.name) {
55
+ apiUrl += `&customAttributes=name=="${flags.name}"`;
56
+ }
57
+ return apiUrl;
58
+ };
59
+ // Output as table, streaming rows as each page is received when fetching all pages
60
+ const table = createTableWriter(['Name', 'Id', 'Type', 'Version', 'Owned By', 'Datacenter Id', 'Service Class Id'], {
61
+ log: (msg) => this.log(msg),
62
+ stream: flags.all && !this.jsonEnabled(),
63
+ streamColumnConfig: {
64
+ 0: { width: 20, wrapWord: true },
65
+ 1: { width: 26 },
66
+ 2: { width: 8 },
67
+ 3: { width: 14 },
68
+ 4: { width: 14 },
69
+ 5: { width: 20 },
70
+ 6: { width: 18 },
71
+ },
72
+ });
73
+ // API calls
74
+ let resp;
75
+ const allData = [];
76
+ for await (const page of fetchPages(conn, buildUrl, {
77
+ all: flags.all,
78
+ pageNumber,
79
+ pageSize,
80
+ })) {
81
+ resp = page;
82
+ allData.push(...page.data);
83
+ table.write(page.data.map((item) => [
67
84
  item.name,
68
85
  item.id,
69
86
  item.type,
@@ -71,11 +88,10 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
71
88
  item.ownedBy,
72
89
  item.datacenterId,
73
90
  item.serviceClassId,
74
- ]),
75
- ];
76
- // Display results as a table
77
- this.log(renderTable(brokerArray));
91
+ ]));
92
+ }
93
+ table.end();
78
94
  // Return raw json if --json flag is set
79
- return resp;
95
+ return { ...resp, data: allData };
80
96
  }
81
97
  }
@@ -0,0 +1,21 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { BrokerVersionListApiResponse } from '../../../types/broker-version.js';
3
+ export default class MissionctrlBrokerVersionList extends ScCommand<typeof MissionctrlBrokerVersionList> {
4
+ static args: {};
5
+ static description: string;
6
+ static examples: string[];
7
+ static flags: {
8
+ sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ 'page-number': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'datacenter-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'family-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'filter-incompatible-versions': import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ recommended: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ 'release-channel': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ };
20
+ run(): Promise<BrokerVersionListApiResponse>;
21
+ }
@@ -0,0 +1,122 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { Flags } from '@oclif/core';
3
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
4
+ import { createTableWriter, DEFAULT_PAGE_SIZE, fetchPages, MAX_PAGE_SIZE, paginationFlags, } from '../../../lib/pagination.js';
5
+ export default class MissionctrlBrokerVersionList extends ScCommand {
6
+ static args = {};
7
+ static description = `Get a list of the event broker versions available for creating event broker services.
8
+
9
+ Use the returned Version values with --version on "sc missionctrl broker create". A service's broker
10
+ version cannot be changed after the service is created.
11
+
12
+ Token Permissions: [ event_broker_versions:get ]`;
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %>',
15
+ '<%= config.bin %> <%= command.id %> --org=my-org',
16
+ '<%= config.bin %> <%= command.id %> --recommended --release-channel=LTS',
17
+ '<%= config.bin %> <%= command.id %> --datacenter-id=eks-ca-central-1a --filter-incompatible-versions',
18
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --family-version=10.25 --all',
19
+ ];
20
+ static flags = {
21
+ alias: Flags.string({
22
+ char: 'a',
23
+ description: 'Organization alias to use. If not specified, uses the default organization.',
24
+ exclusive: ['org'],
25
+ }),
26
+ 'datacenter-id': Flags.string({
27
+ description: 'Id of the datacenter the versions are intended for. Required when --filter-incompatible-versions is set.',
28
+ }),
29
+ 'family-version': Flags.string({
30
+ description: 'Only return versions in this broker family version, for example 10.25. The family version is generally the first two digits of the version number.',
31
+ }),
32
+ 'filter-incompatible-versions': Flags.boolean({
33
+ dependsOn: ['datacenter-id'],
34
+ description: "Exclude versions that are incompatible with the datacenter's Kubernetes version. Requires --datacenter-id. The default value is false.",
35
+ }),
36
+ org: Flags.string({
37
+ char: 'o',
38
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
39
+ exclusive: ['alias'],
40
+ }),
41
+ recommended: Flags.boolean({
42
+ allowNo: true,
43
+ description: 'Only return recommended versions. Use --no-recommended to return only versions that are not recommended. If not specified, all versions are returned.',
44
+ }),
45
+ 'release-channel': Flags.string({
46
+ description: "Filter the versions by release channel. 'LTS' is an annual release with two years of support and maintenance releases, 'ROLLING' is a bi-weekly release introducing new features, and 'DECLINED' versions are unsupported.",
47
+ options: ['PREVIEW', 'PRODUCTION', 'PRODUCTION_LTS', 'LTS', 'ROLLING', 'DECLINED'],
48
+ }),
49
+ ...paginationFlags('event broker versions', { pageNumber: 'p', pageSize: 's' }),
50
+ sort: Flags.string({
51
+ description: 'The query (fieldName:<asc/desc>) used to sort the version list in the response. Defaults to version:desc.',
52
+ }),
53
+ };
54
+ async run() {
55
+ const { flags } = await this.parse(MissionctrlBrokerVersionList);
56
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
57
+ const pageSize = flags['page-size'] ?? (flags.all ? MAX_PAGE_SIZE : DEFAULT_PAGE_SIZE);
58
+ const pageNumber = flags['page-number'] ?? 1;
59
+ const datacenterId = flags['datacenter-id'] ?? '';
60
+ const familyVersion = flags['family-version'] ?? '';
61
+ const filterIncompatibleVersions = flags['filter-incompatible-versions'] ?? false;
62
+ const releaseChannel = flags['release-channel'] ?? '';
63
+ // API url
64
+ const buildUrl = (page, size) => {
65
+ let apiUrl = `/missionControl/eventBrokerServiceVersions?pageSize=${size}&pageNumber=${page}`;
66
+ if (flags.sort) {
67
+ apiUrl += `&sort=${flags.sort}`;
68
+ }
69
+ if (flags.recommended !== undefined) {
70
+ apiUrl += `&recommended=${flags.recommended}`;
71
+ }
72
+ if (releaseChannel) {
73
+ apiUrl += `&releaseChannel=${releaseChannel}`;
74
+ }
75
+ if (familyVersion) {
76
+ apiUrl += `&familyVersion=${familyVersion}`;
77
+ }
78
+ if (datacenterId) {
79
+ apiUrl += `&datacenterId=${datacenterId}`;
80
+ }
81
+ if (filterIncompatibleVersions) {
82
+ apiUrl += `&filterIncompatibleVersions=true`;
83
+ }
84
+ return apiUrl;
85
+ };
86
+ // Output as table, streaming rows as each page is received when fetching all pages
87
+ const table = createTableWriter(['Version', 'Release Channel', 'Recommended', 'Release Date', 'End Of Full Support', 'Min K8s Version'], {
88
+ log: (msg) => this.log(msg),
89
+ stream: flags.all && !this.jsonEnabled(),
90
+ streamColumnConfig: {
91
+ 0: { width: 20 },
92
+ 1: { width: 16 },
93
+ 2: { width: 12 },
94
+ 3: { width: 22 },
95
+ 4: { width: 22 },
96
+ 5: { width: 16 },
97
+ },
98
+ });
99
+ // API calls
100
+ let resp;
101
+ const allData = [];
102
+ for await (const page of fetchPages(conn, buildUrl, {
103
+ all: flags.all,
104
+ pageNumber,
105
+ pageSize,
106
+ })) {
107
+ resp = page;
108
+ allData.push(...page.data);
109
+ table.write(page.data.map((item) => [
110
+ item.version,
111
+ item.releaseChannel,
112
+ item.recommended,
113
+ item.releaseDate,
114
+ item.endOfFullSupport,
115
+ item.minimumK8sVersion,
116
+ ]));
117
+ }
118
+ table.end();
119
+ // Return raw json if --json flag is set
120
+ return { ...resp, data: allData };
121
+ }
122
+ }
@@ -0,0 +1,20 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { DatacenterListApiResponse } from '../../../types/datacenter.js';
3
+ export default class MissionctrlDatacenterList extends ScCommand<typeof MissionctrlDatacenterList> {
4
+ static args: {};
5
+ static description: string;
6
+ static examples: string[];
7
+ static flags: {
8
+ sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ 'page-number': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'datacenter-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'environment-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ provider: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'sam-enabled': import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ };
19
+ run(): Promise<DatacenterListApiResponse>;
20
+ }
@@ -0,0 +1,116 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { Flags } from '@oclif/core';
3
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
4
+ import { createTableWriter, DEFAULT_PAGE_SIZE, fetchPages, MAX_PAGE_SIZE, paginationFlags, } from '../../../lib/pagination.js';
5
+ export default class MissionctrlDatacenterList extends ScCommand {
6
+ static args = {};
7
+ static description = `Get a list of the datacenters available to your account.
8
+
9
+ Use the returned Id values with --datacenter-id on "sc missionctrl broker create". The Supported
10
+ Service Classes column shows which service classes can be deployed to each datacenter.
11
+
12
+ Token Permissions: [ dc:get ]`;
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %>',
15
+ '<%= config.bin %> <%= command.id %> --org=my-org',
16
+ '<%= config.bin %> <%= command.id %> --provider=eks --datacenter-type=SolacePublic',
17
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --environment-id=abcd1234',
18
+ '<%= config.bin %> <%= command.id %> --all',
19
+ ];
20
+ static flags = {
21
+ alias: Flags.string({
22
+ char: 'a',
23
+ description: 'Organization alias to use. If not specified, uses the default organization.',
24
+ exclusive: ['org'],
25
+ }),
26
+ 'datacenter-type': Flags.string({
27
+ description: "Filter the datacenters by type of ownership. 'SolacePublic' are Public Regions shared between customers, 'SolaceDedicated' are Dedicated Regions for a single customer, 'CustomerCloud' and 'CustomerOnPrem' are Customer-Controlled Regions.",
28
+ options: ['Unknown', 'SolacePublic', 'SolaceDedicated', 'CustomerCloud', 'CustomerOnPrem'],
29
+ }),
30
+ 'environment-id': Flags.string({
31
+ description: 'Filter the datacenters by the id of their environment. Public datacenters cannot be filtered by environment.',
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
+ }),
38
+ provider: Flags.string({
39
+ description: "Filter the datacenters by Kubernetes provider: 'aks' (Azure), 'eks' (AWS), 'gcp' (Google), 'k8s' (other), 'container' (Customer-Controlled Containers). 'aws' and 'azure' are deprecated VM-based providers.",
40
+ options: ['aks', 'aws', 'azure', 'container', 'eks', 'gcp', 'k8s'],
41
+ }),
42
+ 'sam-enabled': Flags.boolean({
43
+ allowNo: true,
44
+ description: 'Filter the datacenters by whether SAM is enabled. If not specified, datacenters are returned regardless of their SAM state.',
45
+ }),
46
+ ...paginationFlags('datacenters', { pageNumber: 'p', pageSize: 's' }),
47
+ sort: Flags.string({
48
+ description: 'The query (fieldName:<asc/desc>) used to sort the datacenter list in the response. Defaults to name:asc,datacenterType:asc.',
49
+ }),
50
+ };
51
+ async run() {
52
+ const { flags } = await this.parse(MissionctrlDatacenterList);
53
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
54
+ const pageSize = flags['page-size'] ?? (flags.all ? MAX_PAGE_SIZE : DEFAULT_PAGE_SIZE);
55
+ const pageNumber = flags['page-number'] ?? 1;
56
+ const datacenterType = flags['datacenter-type'] ?? '';
57
+ const environmentId = flags['environment-id'] ?? '';
58
+ const samEnabled = flags['sam-enabled'];
59
+ // API url
60
+ const buildUrl = (page, size) => {
61
+ let apiUrl = `/missionControl/datacenters?pageSize=${size}&pageNumber=${page}`;
62
+ if (flags.sort) {
63
+ apiUrl += `&sort=${flags.sort}`;
64
+ }
65
+ if (datacenterType) {
66
+ apiUrl += `&datacenterType=${datacenterType}`;
67
+ }
68
+ if (flags.provider) {
69
+ apiUrl += `&provider=${flags.provider}`;
70
+ }
71
+ if (environmentId) {
72
+ apiUrl += `&environmentId=${environmentId}`;
73
+ }
74
+ if (samEnabled !== undefined) {
75
+ apiUrl += `&samEnabled=${samEnabled}`;
76
+ }
77
+ return apiUrl;
78
+ };
79
+ // Output as table, streaming rows as each page is received when fetching all pages
80
+ const table = createTableWriter(['Name', 'Id', 'Type', 'Provider', 'Oper State', 'Supported Service Classes'], {
81
+ columnConfig: { 5: { width: 40, wrapWord: true } },
82
+ log: (msg) => this.log(msg),
83
+ stream: flags.all && !this.jsonEnabled(),
84
+ streamColumnConfig: {
85
+ 0: { width: 20, wrapWord: true },
86
+ 1: { width: 24 },
87
+ 2: { width: 18 },
88
+ 3: { width: 10 },
89
+ 4: { width: 11 },
90
+ 5: { width: 40, wrapWord: true },
91
+ },
92
+ });
93
+ // API calls
94
+ let resp;
95
+ const allData = [];
96
+ for await (const page of fetchPages(conn, buildUrl, {
97
+ all: flags.all,
98
+ pageNumber,
99
+ pageSize,
100
+ })) {
101
+ resp = page;
102
+ allData.push(...page.data);
103
+ table.write(page.data.map((item) => [
104
+ item.name,
105
+ item.id,
106
+ item.datacenterType,
107
+ item.provider,
108
+ item.operState,
109
+ (item.supportedServiceClasses ?? []).join(', '),
110
+ ]));
111
+ }
112
+ table.end();
113
+ // Return raw json if --json flag is set
114
+ return { ...resp, data: allData };
115
+ }
116
+ }
@@ -0,0 +1,13 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { ServiceClassListApiResponse } from '../../../types/service-class.js';
3
+ export default class MissionctrlServiceClassList extends ScCommand<typeof MissionctrlServiceClassList> {
4
+ static args: {};
5
+ static description: string;
6
+ static examples: string[];
7
+ static flags: {
8
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'broker-family-version': 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>;
11
+ };
12
+ run(): Promise<ServiceClassListApiResponse>;
13
+ }
@@ -0,0 +1,61 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { Flags } from '@oclif/core';
3
+ import { resolveOrgConnection } from '../../../lib/org-utils.js';
4
+ import { createTableWriter } from '../../../lib/pagination.js';
5
+ export default class MissionctrlServiceClassList extends ScCommand {
6
+ static args = {};
7
+ static description = `Get a list of the service classes available in your account.
8
+
9
+ Use the returned Id values with --service-class-id on "sc missionctrl broker create". Standalone
10
+ service classes are only returned once they have been added to your account's Service Limits.
11
+
12
+ Token Permissions: [ service_classes:get ]`;
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %>',
15
+ '<%= config.bin %> <%= command.id %> --org=my-org',
16
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --broker-family-version=10.25',
17
+ ];
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
+ }),
24
+ 'broker-family-version': Flags.string({
25
+ description: 'Only return service classes available for this broker family version, for example 10.25. If not specified, all service classes are returned.',
26
+ }),
27
+ org: Flags.string({
28
+ char: 'o',
29
+ description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
30
+ exclusive: ['alias'],
31
+ }),
32
+ };
33
+ async run() {
34
+ const { flags } = await this.parse(MissionctrlServiceClassList);
35
+ const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
36
+ const brokerFamilyVersion = flags['broker-family-version'] ?? '';
37
+ // API url - this endpoint is not paginated
38
+ let apiUrl = '/missionControl/serviceClasses';
39
+ if (brokerFamilyVersion) {
40
+ apiUrl += `?brokerFamilyVersion=${brokerFamilyVersion}`;
41
+ }
42
+ // API call
43
+ const resp = await conn.get(apiUrl);
44
+ // Output as table
45
+ const table = createTableWriter(['Name', 'Id', 'Connections', 'Max Spool (GB)', 'HA Capable', 'Scaling Tier'], {
46
+ log: (msg) => this.log(msg),
47
+ stream: false,
48
+ });
49
+ table.write(resp.data.map((item) => [
50
+ item.name,
51
+ item.id,
52
+ item.vpnConnections,
53
+ item.vpnMaxSpoolSize,
54
+ item.highAvailabilityCapable,
55
+ item.brokerScalingTier,
56
+ ]));
57
+ table.end();
58
+ // Return raw json if --json flag is set
59
+ return resp;
60
+ }
61
+ }
@@ -5,12 +5,13 @@ export default class PlatformEnvList extends ScCommand<typeof PlatformEnvList> {
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
+ sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ 'page-number': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
12
  alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
13
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
14
  org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- pageNumber: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- pageSize: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
15
  };
15
16
  run(): Promise<EnvironmentListApiResponse>;
16
17
  }
@@ -1,6 +1,7 @@
1
- import { renderTable, ScCommand } from '@dishantlangayan/sc-cli-core';
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
2
  import { Flags } from '@oclif/core';
3
3
  import { resolveOrgConnection } from '../../../lib/org-utils.js';
4
+ import { createTableWriter, DEFAULT_PAGE_SIZE, fetchPages, MAX_PAGE_SIZE, paginationFlags, } from '../../../lib/pagination.js';
4
5
  export default class PlatformEnvList extends ScCommand {
5
6
  static args = {};
6
7
  static description = `Get a list of all Environments.
@@ -9,7 +10,8 @@ export default class PlatformEnvList extends ScCommand {
9
10
  static examples = [
10
11
  '<%= config.bin %> <%= command.id %>',
11
12
  '<%= config.bin %> <%= command.id %> --org=my-org',
12
- '<%= config.bin %> <%= command.id %> --alias=my-alias --name=Default --pageNumber=1 --pageSize=10 --sort=name:ASC',
13
+ '<%= config.bin %> <%= command.id %> --alias=my-alias --name=Default --page-number=1 --page-size=10 --sort=name:ASC',
14
+ '<%= config.bin %> <%= command.id %> --all',
13
15
  ];
14
16
  static flags = {
15
17
  alias: Flags.string({
@@ -26,16 +28,7 @@ export default class PlatformEnvList extends ScCommand {
26
28
  description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
27
29
  exclusive: ['alias'],
28
30
  }),
29
- pageNumber: Flags.integer({
30
- char: 'p',
31
- description: 'The page number to get. Defaults to 10',
32
- }),
33
- pageSize: Flags.integer({
34
- char: 's',
35
- description: 'The number of environments to get per page. Defaults to 1',
36
- max: 100,
37
- min: 1,
38
- }),
31
+ ...paginationFlags('environments', { pageNumber: 'p', pageSize: 's' }),
39
32
  sort: Flags.string({
40
33
  description: 'The query (fieldName:<ASC/DESC>) used to sort the environment list in the response.',
41
34
  }),
@@ -43,29 +36,49 @@ export default class PlatformEnvList extends ScCommand {
43
36
  async run() {
44
37
  const { flags } = await this.parse(PlatformEnvList);
45
38
  const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
46
- const pageSize = flags.pageSize ?? 10;
47
- const pageNumber = flags.pageNumber ?? 1;
39
+ const pageSize = flags['page-size'] ?? (flags.all ? MAX_PAGE_SIZE : DEFAULT_PAGE_SIZE);
40
+ const pageNumber = flags['page-number'] ?? 1;
48
41
  // API url
49
- let apiUrl = `/platform/environments?pageSize=${pageSize}&pageNumber=${pageNumber}`;
50
- if (flags.sort) {
51
- apiUrl += `&sort=${flags.sort}`;
52
- }
53
- // API call
54
- const resp = await conn.get(apiUrl);
55
- // Array to output as table
56
- const envArray = [
57
- ['Name', 'Id', 'Is Default', 'Is Production', 'Description'],
58
- ...resp.data.map((item) => [
42
+ const buildUrl = (page, size) => {
43
+ let apiUrl = `/platform/environments?pageSize=${size}&pageNumber=${page}`;
44
+ if (flags.sort) {
45
+ apiUrl += `&sort=${flags.sort}`;
46
+ }
47
+ return apiUrl;
48
+ };
49
+ // Output as table, streaming rows as each page is received when fetching all pages
50
+ const table = createTableWriter(['Name', 'Id', 'Is Default', 'Is Production', 'Description'], {
51
+ columnConfig: { 4: { width: 50, wrapWord: true } },
52
+ log: (msg) => this.log(msg),
53
+ stream: flags.all && !this.jsonEnabled(),
54
+ streamColumnConfig: {
55
+ 0: { width: 20, wrapWord: true },
56
+ 1: { width: 26 },
57
+ 2: { width: 10 },
58
+ 3: { width: 13 },
59
+ 4: { width: 50, wrapWord: true },
60
+ },
61
+ });
62
+ // API calls
63
+ let resp;
64
+ const allData = [];
65
+ for await (const page of fetchPages(conn, buildUrl, {
66
+ all: flags.all,
67
+ pageNumber,
68
+ pageSize,
69
+ })) {
70
+ resp = page;
71
+ allData.push(...page.data);
72
+ table.write(page.data.map((item) => [
59
73
  item.name,
60
74
  item.id,
61
75
  item.isDefault,
62
76
  item.isProduction,
63
77
  item.description,
64
- ]),
65
- ];
66
- // Display results as a table
67
- this.log(renderTable(envArray, { 4: { width: 50, wrapWord: true } }));
78
+ ]));
79
+ }
80
+ table.end();
68
81
  // Return raw json if --json flag is set
69
- return resp;
82
+ return { ...resp, data: allData };
70
83
  }
71
84
  }
@@ -0,0 +1,20 @@
1
+ import { ScCommand } from '@dishantlangayan/sc-cli-core';
2
+ import { UserListApiResponse } from '../../../types/user.js';
3
+ export default class PlatformUsersList extends ScCommand<typeof PlatformUsersList> {
4
+ static args: {};
5
+ static description: string;
6
+ static examples: string[];
7
+ static flags: {
8
+ role: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ 'page-number': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'page-size': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ alias: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ email: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ group: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ id: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ };
19
+ run(): Promise<UserListApiResponse>;
20
+ }