@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.
- package/README.md +604 -152
- package/dist/commands/missionctrl/broker/list.d.ts +4 -3
- package/dist/commands/missionctrl/broker/list.js +46 -30
- package/dist/commands/missionctrl/broker-version/list.d.ts +21 -0
- package/dist/commands/missionctrl/broker-version/list.js +122 -0
- package/dist/commands/missionctrl/datacenter/list.d.ts +20 -0
- package/dist/commands/missionctrl/datacenter/list.js +116 -0
- package/dist/commands/missionctrl/service-class/list.d.ts +13 -0
- package/dist/commands/missionctrl/service-class/list.js +61 -0
- package/dist/commands/platform/env/list.d.ts +4 -3
- package/dist/commands/platform/env/list.js +42 -29
- package/dist/commands/platform/users/list.d.ts +20 -0
- package/dist/commands/platform/users/list.js +105 -0
- package/dist/lib/pagination.d.ts +76 -0
- package/dist/lib/pagination.js +96 -0
- package/dist/types/broker-version.d.ts +29 -0
- package/dist/types/broker-version.js +1 -0
- package/dist/types/datacenter.d.ts +41 -0
- package/dist/types/datacenter.js +1 -0
- package/dist/types/service-class.d.ts +21 -0
- package/dist/types/service-class.js +1 -0
- package/dist/types/user.d.ts +31 -0
- package/dist/types/user.js +1 -0
- package/oclif.manifest.json +552 -14
- package/package.json +8 -5
|
@@ -0,0 +1,105 @@
|
|
|
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 PlatformUsersList extends ScCommand {
|
|
6
|
+
static args = {};
|
|
7
|
+
static description = `(Beta) Get a list of users in your account.
|
|
8
|
+
|
|
9
|
+
You can retrieve a list of users matching on email, name, identifiers, roles, or groups.
|
|
10
|
+
The --name and --email filters match on partial strings.
|
|
11
|
+
|
|
12
|
+
Required token permissions: [ iam_users: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 --name=Jane --page-number=1 --page-size=10',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> --email=jane@example.com',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --role=role-id-1 --role=role-id-2',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --all',
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
alias: Flags.string({
|
|
23
|
+
char: 'a',
|
|
24
|
+
description: 'Organization alias to use. If not specified, uses the default organization.',
|
|
25
|
+
exclusive: ['org'],
|
|
26
|
+
}),
|
|
27
|
+
email: Flags.string({
|
|
28
|
+
description: 'The email address of the user. You can enter a partial string into the field to match multiple users.',
|
|
29
|
+
}),
|
|
30
|
+
group: Flags.string({
|
|
31
|
+
description: 'The unique identifier of a group that is assigned to the user. Repeat the flag to match on multiple groups.',
|
|
32
|
+
multiple: true,
|
|
33
|
+
}),
|
|
34
|
+
id: Flags.string({
|
|
35
|
+
description: 'The unique identifier of a user. Repeat the flag to match on multiple users.',
|
|
36
|
+
multiple: true,
|
|
37
|
+
}),
|
|
38
|
+
name: Flags.string({
|
|
39
|
+
char: 'n',
|
|
40
|
+
description: 'The name of the user. You can enter a partial string into the field to match multiple users.',
|
|
41
|
+
}),
|
|
42
|
+
org: Flags.string({
|
|
43
|
+
char: 'o',
|
|
44
|
+
description: 'Organization ID to use. If not specified, uses the default organization or alias if specified.',
|
|
45
|
+
exclusive: ['alias'],
|
|
46
|
+
}),
|
|
47
|
+
...paginationFlags('users', { pageNumber: 'p', pageSize: 's' }),
|
|
48
|
+
role: Flags.string({
|
|
49
|
+
description: 'The unique identifier of a role that is assigned to the user. Repeat the flag to match on multiple roles.',
|
|
50
|
+
multiple: true,
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
async run() {
|
|
54
|
+
const { flags } = await this.parse(PlatformUsersList);
|
|
55
|
+
const conn = await resolveOrgConnection(this, flags.org ?? flags.alias);
|
|
56
|
+
const pageSize = flags['page-size'] ?? (flags.all ? MAX_PAGE_SIZE : DEFAULT_PAGE_SIZE);
|
|
57
|
+
const pageNumber = flags['page-number'] ?? 1;
|
|
58
|
+
// API url
|
|
59
|
+
// The ids, roles, and groups query parameters are arrays, so each value is repeated
|
|
60
|
+
const buildUrl = (page, size) => {
|
|
61
|
+
const params = new URLSearchParams();
|
|
62
|
+
params.append('pageSize', String(size));
|
|
63
|
+
params.append('pageNumber', String(page));
|
|
64
|
+
if (flags.name)
|
|
65
|
+
params.append('name', flags.name);
|
|
66
|
+
if (flags.email)
|
|
67
|
+
params.append('email', flags.email);
|
|
68
|
+
for (const id of flags.id ?? [])
|
|
69
|
+
params.append('ids', id);
|
|
70
|
+
for (const role of flags.role ?? [])
|
|
71
|
+
params.append('roles', role);
|
|
72
|
+
for (const group of flags.group ?? [])
|
|
73
|
+
params.append('groups', group);
|
|
74
|
+
return `/platform/users?${params.toString()}`;
|
|
75
|
+
};
|
|
76
|
+
// Output as table, streaming rows as each page is received when fetching all pages
|
|
77
|
+
const table = createTableWriter(['Email', 'First Name', 'Last Name', 'Id', 'State'], {
|
|
78
|
+
columnConfig: { 0: { width: 30, wrapWord: true } },
|
|
79
|
+
log: (msg) => this.log(msg),
|
|
80
|
+
stream: flags.all && !this.jsonEnabled(),
|
|
81
|
+
streamColumnConfig: {
|
|
82
|
+
0: { width: 30, wrapWord: true },
|
|
83
|
+
1: { width: 15, wrapWord: true },
|
|
84
|
+
2: { width: 15, wrapWord: true },
|
|
85
|
+
3: { width: 26 },
|
|
86
|
+
4: { width: 16 },
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
// API calls
|
|
90
|
+
let resp;
|
|
91
|
+
const allData = [];
|
|
92
|
+
for await (const page of fetchPages(conn, buildUrl, {
|
|
93
|
+
all: flags.all,
|
|
94
|
+
pageNumber,
|
|
95
|
+
pageSize,
|
|
96
|
+
})) {
|
|
97
|
+
resp = page;
|
|
98
|
+
allData.push(...page.data);
|
|
99
|
+
table.write(page.data.map((item) => [item.email, item.firstName, item.lastName, item.id, item.state]));
|
|
100
|
+
}
|
|
101
|
+
table.end();
|
|
102
|
+
// Return raw json if --json flag is set
|
|
103
|
+
return { ...resp, data: allData };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ColumnConfig, ScConnection } from '@dishantlangayan/sc-cli-core';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal shape of a paginated Solace Cloud API list response
|
|
4
|
+
*/
|
|
5
|
+
export interface PaginatedApiResponse<T> {
|
|
6
|
+
data: T[];
|
|
7
|
+
meta?: {
|
|
8
|
+
pagination?: {
|
|
9
|
+
count: number;
|
|
10
|
+
nextPage: null | string;
|
|
11
|
+
pageNumber: number;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const DEFAULT_PAGE_SIZE = 10;
|
|
18
|
+
export declare const MAX_PAGE_SIZE = 100;
|
|
19
|
+
/**
|
|
20
|
+
* Builds the standard pagination flags (--page-number, --page-size, --all) for list commands.
|
|
21
|
+
*
|
|
22
|
+
* @param resourceName - Plural name of the listed resource, used in flag descriptions
|
|
23
|
+
* @param chars - Optional short characters for the flags
|
|
24
|
+
* @param chars.pageNumber - Short character for --page-number
|
|
25
|
+
* @param chars.pageSize - Short character for --page-size
|
|
26
|
+
* @returns Pagination flag definitions to spread into a command's flags
|
|
27
|
+
*/
|
|
28
|
+
export declare function paginationFlags(resourceName: string, chars?: {
|
|
29
|
+
pageNumber?: 'p';
|
|
30
|
+
pageSize?: 's';
|
|
31
|
+
}): {
|
|
32
|
+
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
|
+
'page-number': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
|
+
'page-size': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Iterates over the pages of a paginated list API, yielding each page as soon as it is received.
|
|
38
|
+
*
|
|
39
|
+
* @param conn - Authenticated connection used to call the API
|
|
40
|
+
* @param buildUrl - Builds the API url for the given page number and page size
|
|
41
|
+
* @param options - Paging options
|
|
42
|
+
* @param options.all - Whether to follow all subsequent pages
|
|
43
|
+
* @param options.pageNumber - Page number to start from
|
|
44
|
+
* @param options.pageSize - Number of items per page
|
|
45
|
+
* @yields Each page's API response
|
|
46
|
+
*/
|
|
47
|
+
export declare function fetchPages<T, R extends PaginatedApiResponse<T>>(conn: ScConnection, buildUrl: (pageNumber: number, pageSize: number) => string, options: {
|
|
48
|
+
all: boolean;
|
|
49
|
+
pageNumber: number;
|
|
50
|
+
pageSize: number;
|
|
51
|
+
}): AsyncGenerator<R>;
|
|
52
|
+
export interface TableWriter {
|
|
53
|
+
end(): void;
|
|
54
|
+
write(rows: unknown[][]): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a table writer for list output.
|
|
58
|
+
*
|
|
59
|
+
* When streaming is requested and stdout is a TTY, rows are appended to the table as they are written.
|
|
60
|
+
* Otherwise (e.g. output is piped), rows are buffered and rendered as a single table on end(), since the
|
|
61
|
+
* stream table relies on terminal escape sequences to redraw its bottom border.
|
|
62
|
+
*
|
|
63
|
+
* @param header - Table header row
|
|
64
|
+
* @param options - Output options
|
|
65
|
+
* @param options.columnConfig - Column configuration for the rendered (non-streamed) table
|
|
66
|
+
* @param options.log - Logger used to print the rendered table
|
|
67
|
+
* @param options.stream - Whether to stream rows to the table as they are written
|
|
68
|
+
* @param options.streamColumnConfig - Fixed column widths for the stream table
|
|
69
|
+
* @returns A writer that accepts batches of rows
|
|
70
|
+
*/
|
|
71
|
+
export declare function createTableWriter(header: string[], options: {
|
|
72
|
+
columnConfig?: Record<number, ColumnConfig>;
|
|
73
|
+
log: (msg: string) => void;
|
|
74
|
+
stream: boolean;
|
|
75
|
+
streamColumnConfig?: Record<number, ColumnConfig>;
|
|
76
|
+
}): TableWriter;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createStreamTable, renderTable } from '@dishantlangayan/sc-cli-core';
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
|
+
export const DEFAULT_PAGE_SIZE = 10;
|
|
4
|
+
export const MAX_PAGE_SIZE = 100;
|
|
5
|
+
/**
|
|
6
|
+
* Builds the standard pagination flags (--page-number, --page-size, --all) for list commands.
|
|
7
|
+
*
|
|
8
|
+
* @param resourceName - Plural name of the listed resource, used in flag descriptions
|
|
9
|
+
* @param chars - Optional short characters for the flags
|
|
10
|
+
* @param chars.pageNumber - Short character for --page-number
|
|
11
|
+
* @param chars.pageSize - Short character for --page-size
|
|
12
|
+
* @returns Pagination flag definitions to spread into a command's flags
|
|
13
|
+
*/
|
|
14
|
+
export function paginationFlags(resourceName, chars = {}) {
|
|
15
|
+
return {
|
|
16
|
+
all: Flags.boolean({
|
|
17
|
+
default: false,
|
|
18
|
+
description: `Fetch all pages of ${resourceName}. Results are streamed to the table as each page is received.`,
|
|
19
|
+
exclusive: ['page-number'],
|
|
20
|
+
}),
|
|
21
|
+
'page-number': Flags.integer({
|
|
22
|
+
char: chars.pageNumber,
|
|
23
|
+
description: 'The page number to get. Defaults to 1',
|
|
24
|
+
min: 1,
|
|
25
|
+
}),
|
|
26
|
+
'page-size': Flags.integer({
|
|
27
|
+
char: chars.pageSize,
|
|
28
|
+
description: `The number of ${resourceName} to return per page. Defaults to ${DEFAULT_PAGE_SIZE}, or ${MAX_PAGE_SIZE} when --all is set`,
|
|
29
|
+
max: MAX_PAGE_SIZE,
|
|
30
|
+
min: 1,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Iterates over the pages of a paginated list API, yielding each page as soon as it is received.
|
|
36
|
+
*
|
|
37
|
+
* @param conn - Authenticated connection used to call the API
|
|
38
|
+
* @param buildUrl - Builds the API url for the given page number and page size
|
|
39
|
+
* @param options - Paging options
|
|
40
|
+
* @param options.all - Whether to follow all subsequent pages
|
|
41
|
+
* @param options.pageNumber - Page number to start from
|
|
42
|
+
* @param options.pageSize - Number of items per page
|
|
43
|
+
* @yields Each page's API response
|
|
44
|
+
*/
|
|
45
|
+
export async function* fetchPages(conn, buildUrl, options) {
|
|
46
|
+
let { pageNumber } = options;
|
|
47
|
+
while (true) {
|
|
48
|
+
// eslint-disable-next-line no-await-in-loop
|
|
49
|
+
const resp = await conn.get(buildUrl(pageNumber, options.pageSize));
|
|
50
|
+
yield resp;
|
|
51
|
+
const totalPages = resp.meta?.pagination?.totalPages ?? pageNumber;
|
|
52
|
+
if (!options.all || pageNumber >= totalPages || resp.data.length === 0) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
pageNumber++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a table writer for list output.
|
|
60
|
+
*
|
|
61
|
+
* When streaming is requested and stdout is a TTY, rows are appended to the table as they are written.
|
|
62
|
+
* Otherwise (e.g. output is piped), rows are buffered and rendered as a single table on end(), since the
|
|
63
|
+
* stream table relies on terminal escape sequences to redraw its bottom border.
|
|
64
|
+
*
|
|
65
|
+
* @param header - Table header row
|
|
66
|
+
* @param options - Output options
|
|
67
|
+
* @param options.columnConfig - Column configuration for the rendered (non-streamed) table
|
|
68
|
+
* @param options.log - Logger used to print the rendered table
|
|
69
|
+
* @param options.stream - Whether to stream rows to the table as they are written
|
|
70
|
+
* @param options.streamColumnConfig - Fixed column widths for the stream table
|
|
71
|
+
* @returns A writer that accepts batches of rows
|
|
72
|
+
*/
|
|
73
|
+
export function createTableWriter(header, options) {
|
|
74
|
+
if (options.stream && process.stdout.isTTY) {
|
|
75
|
+
const streamTable = createStreamTable(header.length, options.streamColumnConfig);
|
|
76
|
+
streamTable.write(header);
|
|
77
|
+
return {
|
|
78
|
+
end() {
|
|
79
|
+
process.stdout.write('\n');
|
|
80
|
+
},
|
|
81
|
+
write(rows) {
|
|
82
|
+
for (const row of rows)
|
|
83
|
+
streamTable.write(row.map(String));
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const buffered = [header];
|
|
88
|
+
return {
|
|
89
|
+
end() {
|
|
90
|
+
options.log(renderTable(buffered, options.columnConfig));
|
|
91
|
+
},
|
|
92
|
+
write(rows) {
|
|
93
|
+
buffered.push(...rows);
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface EventBrokerServiceVersion {
|
|
2
|
+
capabilities?: string[];
|
|
3
|
+
containerImageTag?: string;
|
|
4
|
+
currentMcaVersion?: string;
|
|
5
|
+
endOfFullSupport?: string;
|
|
6
|
+
endOfTechnicalSupport?: string;
|
|
7
|
+
id: string;
|
|
8
|
+
minimumK8sVersion?: string;
|
|
9
|
+
minimumMcaVersion?: string;
|
|
10
|
+
recommended?: boolean;
|
|
11
|
+
releaseChannel?: string;
|
|
12
|
+
releaseDate?: string;
|
|
13
|
+
releaseNotes?: string;
|
|
14
|
+
supportedServiceClasses?: string[];
|
|
15
|
+
type?: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface BrokerVersionListApiResponse {
|
|
19
|
+
data: EventBrokerServiceVersion[];
|
|
20
|
+
meta?: {
|
|
21
|
+
pagination?: {
|
|
22
|
+
count: number;
|
|
23
|
+
nextPage: null | string;
|
|
24
|
+
pageNumber: number;
|
|
25
|
+
pageSize: number;
|
|
26
|
+
totalPages: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface Location {
|
|
2
|
+
continent: string;
|
|
3
|
+
latitude: string;
|
|
4
|
+
longitude: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Datacenter {
|
|
7
|
+
available?: boolean;
|
|
8
|
+
cloudAgentVersion?: string;
|
|
9
|
+
createdBy?: string;
|
|
10
|
+
createdTime?: string;
|
|
11
|
+
datacenterType?: string;
|
|
12
|
+
environmentId?: string;
|
|
13
|
+
id: string;
|
|
14
|
+
k8sServiceType?: string;
|
|
15
|
+
location?: Location;
|
|
16
|
+
name?: string;
|
|
17
|
+
numSupportedPrivateEndpoints?: number;
|
|
18
|
+
numSupportedPublicEndpoints?: number;
|
|
19
|
+
operState?: string;
|
|
20
|
+
organizationId?: string;
|
|
21
|
+
provider?: string;
|
|
22
|
+
regionId?: string;
|
|
23
|
+
selfServeEventBrokerUpgradesEnabled?: boolean;
|
|
24
|
+
supportedServiceClasses?: string[];
|
|
25
|
+
type?: string;
|
|
26
|
+
updatedBy?: string;
|
|
27
|
+
updatedTime?: string;
|
|
28
|
+
visible?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface DatacenterListApiResponse {
|
|
31
|
+
data: Datacenter[];
|
|
32
|
+
meta?: {
|
|
33
|
+
pagination?: {
|
|
34
|
+
count: number;
|
|
35
|
+
nextPage: null | string;
|
|
36
|
+
pageNumber: number;
|
|
37
|
+
pageSize: number;
|
|
38
|
+
totalPages: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface LimitClassUsage {
|
|
2
|
+
inUse?: number;
|
|
3
|
+
limit?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ServiceClass {
|
|
6
|
+
brokerScalingTier?: string;
|
|
7
|
+
highAvailabilityCapable?: boolean;
|
|
8
|
+
id: string;
|
|
9
|
+
limits?: LimitClassUsage[];
|
|
10
|
+
maxNumberVpns?: number;
|
|
11
|
+
name?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
vpnConnections?: number;
|
|
14
|
+
vpnMaxSpoolSize?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ServiceClassListApiResponse {
|
|
17
|
+
data: ServiceClass[];
|
|
18
|
+
meta?: {
|
|
19
|
+
additionalProp?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface GroupInfo {
|
|
2
|
+
id?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface User {
|
|
6
|
+
email?: string;
|
|
7
|
+
firstName?: string;
|
|
8
|
+
groups?: GroupInfo[];
|
|
9
|
+
id?: string;
|
|
10
|
+
lastName?: string;
|
|
11
|
+
organizationId?: string;
|
|
12
|
+
roles?: string[];
|
|
13
|
+
state?: string;
|
|
14
|
+
type?: string;
|
|
15
|
+
userAttributes?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export interface UserListApiResponse {
|
|
18
|
+
data: User[];
|
|
19
|
+
meta: {
|
|
20
|
+
pagination: {
|
|
21
|
+
count: number;
|
|
22
|
+
nextPage: null | string;
|
|
23
|
+
pageNumber: number;
|
|
24
|
+
pageSize: number;
|
|
25
|
+
totalPages: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface UserApiResponse {
|
|
30
|
+
data: User;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|