Skip to content

Commit 6e86137

Browse files
Update all commands to use new login auth approach using OrgManager.
1 parent c1e8a61 commit 6e86137

22 files changed

Lines changed: 403 additions & 93 deletions

src/commands/missionctrl/broker/create.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {printObjectAsKeyValueTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {printObjectAsKeyValueTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EventBrokerOperationApiResponse} from '../../../types/broker.js'
56

67
export default class MissionctrlBrokerCreate extends ScCommand<typeof MissionctrlBrokerCreate> {
@@ -12,6 +13,7 @@ Your token must have one of the permissions listed in the Token Permissions.
1213
Token Permissions: [ \`services:post\` ]`
1314
static override examples = [
1415
'<%= config.bin %> <%= command.id %> --name=MyBrokerName --datacenter-id=eks-ca-central-1a --service-class-id=DEVELOPER',
16+
'<%= config.bin %> <%= command.id %> --org=my-org --name=MyBrokerName --datacenter-id=eks-ca-central-1a --service-class-id=DEVELOPER',
1517
]
1618
static override flags = {
1719
'datacenter-id': Flags.string({
@@ -46,6 +48,10 @@ Token Permissions: [ \`services:post\` ]`
4648
description: 'Name of the event broker service to create.',
4749
required: true,
4850
}),
51+
org: Flags.string({
52+
char: 'o',
53+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
54+
}),
4955
'redundancy-group-ssl-enabled': Flags.boolean({
5056
char: 'r',
5157
default: false,
@@ -77,7 +83,7 @@ Token Permissions: [ \`services:post\` ]`
7783
const eventBrokerVersion = flags.version ?? ''
7884
let envId: string = ''
7985

80-
const conn = new ScConnection()
86+
const conn = await resolveOrgConnection(this, flags.org)
8187

8288
// API url
8389
const apiUrl: string = `/missionControl/eventBrokerServices`

src/commands/missionctrl/broker/delete.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {printObjectAsKeyValueTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {printObjectAsKeyValueTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EventBrokerListApiResponse, EventBrokerOperationApiResponse} from '../../../types/broker.js'
56

67
export default class MissionctrlBrokerDelete extends ScCommand<typeof MissionctrlBrokerDelete> {
@@ -13,6 +14,7 @@ Token Permissions: [ \`services:delete\` **or** \`services:delete:self\` **or**
1314
static override examples = [
1415
'<%= config.bin %> <%= command.id %> --broker-id=MyBrokerId',
1516
'<%= config.bin %> <%= command.id %> --name=MyBrokerName',
17+
'<%= config.bin %> <%= command.id %> --org=my-org --broker-id=MyBrokerId',
1618
]
1719
static override flags = {
1820
'broker-id': Flags.string({
@@ -25,6 +27,10 @@ Token Permissions: [ \`services:delete\` **or** \`services:delete:self\` **or**
2527
description: 'Name of the event broker service.',
2628
exactlyOne: ['broker-id', 'name'],
2729
}),
30+
org: Flags.string({
31+
char: 'o',
32+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
33+
}),
2834
}
2935

3036
public async run(): Promise<EventBrokerOperationApiResponse> {
@@ -33,7 +39,7 @@ Token Permissions: [ \`services:delete\` **or** \`services:delete:self\` **or**
3339
const name = flags.name ?? ''
3440
const brokerId = flags['broker-id'] ?? ''
3541

36-
const conn = new ScConnection()
42+
const conn = await resolveOrgConnection(this, flags.org)
3743

3844
// API url
3945
let apiUrl: string = `/missionControl/eventBrokerServices`

src/commands/missionctrl/broker/display.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {printObjectAsKeyValueTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {printObjectAsKeyValueTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EventBrokerApiResponse, EventBrokerListApiResponse} from '../../../types/broker.js'
56

67
export default class MissionctrlBrokerDisplay extends ScCommand<typeof MissionctrlBrokerDisplay> {
@@ -10,7 +11,10 @@ export default class MissionctrlBrokerDisplay extends ScCommand<typeof Missionct
1011
Use either the Event Broker's ID (--broker-id) or name of the Event Broker (--name).
1112
1213
Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \`services:get:self\` **or** \`services:view\` **or** \`services:view:self\` ]`
13-
static override examples = ['<%= config.bin %> <%= command.id %>']
14+
static override examples = [
15+
'<%= config.bin %> <%= command.id %> --broker-id=MyBrokerId',
16+
'<%= config.bin %> <%= command.id %> --org=my-org --name=MyBrokerName',
17+
]
1418
static override flags = {
1519
'broker-id': Flags.string({
1620
char: 'b',
@@ -22,6 +26,10 @@ export default class MissionctrlBrokerDisplay extends ScCommand<typeof Missionct
2226
description: 'Name of the event broker service.',
2327
exactlyOne: ['broker-id', 'name'],
2428
}),
29+
org: Flags.string({
30+
char: 'o',
31+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
32+
}),
2533
}
2634

2735
public async run(): Promise<EventBrokerApiResponse | EventBrokerListApiResponse> {
@@ -30,7 +38,7 @@ export default class MissionctrlBrokerDisplay extends ScCommand<typeof Missionct
3038
const name = flags.name ?? ''
3139
const brokerId = flags['broker-id'] ?? ''
3240

33-
const conn = new ScConnection()
41+
const conn = await resolveOrgConnection(this, flags.org)
3442

3543
// API url
3644
let apiUrl: string = `/missionControl/eventBrokerServices`

src/commands/missionctrl/broker/list.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {renderTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {renderTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EventBrokerListApiResponse, EventBrokerServiceDetail} from '../../../types/broker.js'
56

67
export default class MissionctrlBrokerList extends ScCommand<typeof MissionctrlBrokerList> {
@@ -12,13 +13,18 @@ Your token must have one of the permissions listed in the Token Permissions.
1213
Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \`services:get:self\` **or** \`services:view\` **or** \`services:view:self\` ]`
1314
static override examples = [
1415
'<%= config.bin %> <%= command.id %>',
16+
'<%= config.bin %> <%= command.id %> --org=my-org',
1517
'<%= config.bin %> <%= command.id %> --name=MyBrokerName --pageNumber=1 --pageSize=10 --sort=name:asc',
1618
]
1719
static override flags = {
1820
name: Flags.string({
1921
char: 'n',
2022
description: 'Name of the event broker service to match on.',
2123
}),
24+
org: Flags.string({
25+
char: 'o',
26+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
27+
}),
2228
pageNumber: Flags.integer({
2329
description: 'The page number to get. Defaults to 1',
2430
}),
@@ -40,7 +46,7 @@ Token Permissions: [ \`mission_control:access\` **or** \`services:get\` **or** \
4046
public async run(): Promise<EventBrokerListApiResponse> {
4147
const {flags} = await this.parse(MissionctrlBrokerList)
4248

43-
const conn = new ScConnection()
49+
const conn = await resolveOrgConnection(this, flags.org)
4450

4551
const pageSize = flags.pageSize ?? 10
4652
const pageNumber = flags.pageNumber ?? 1

src/commands/missionctrl/broker/opstatus.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import {renderTable, ScCommand, ScConnection, sleep} from '@dishantlangayan/sc-c
22
import {Flags} from '@oclif/core'
33
import {MultiBar, Presets, SingleBar} from 'cli-progress'
44

5+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
56
import {
67
EventBrokerAllOperationsApiResponse,
78
EventBrokerListApiResponse,
89
EventBrokerOperationApiResponse,
910
EventBrokerOperationDetail,
11+
ProgressLog,
1012
} from '../../../types/broker.js'
1113

1214
export default class MissionctrlBrokerOpstatus extends ScCommand<typeof MissionctrlBrokerOpstatus> {
@@ -18,6 +20,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
1820
static override examples = [
1921
'<%= config.bin %> <%= command.id %> -b <broker-id>',
2022
'<%= config.bin %> <%= command.id %> -n <broker-name>',
23+
'<%= config.bin %> <%= command.id %> --org=my-org -b <broker-id>',
2124
]
2225
static override flags = {
2326
'broker-id': Flags.string({
@@ -30,6 +33,10 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
3033
description: 'Name of the event broker service.',
3134
exactlyOne: ['broker-id', 'name'],
3235
}),
36+
org: Flags.string({
37+
char: 'o',
38+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
39+
}),
3340
'show-progress': Flags.boolean({
3441
char: 'p',
3542
description:
@@ -50,7 +57,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
5057
const showProgress = flags['show-progress'] ?? false
5158
const waitMs = flags['wait-ms'] ?? 5000
5259

53-
const conn = new ScConnection()
60+
const conn = await resolveOrgConnection(this, flags.org)
5461

5562
// Base API url
5663
let apiUrl: string = `/missionControl/eventBrokerServices`
@@ -119,7 +126,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
119126
// start a new progress bar for the operation with a total value of size of the steps
120127
const progressBar = multiProgressBar.create(numSteps, 0, {operationType: operationData.operationType})
121128
// Update the progress with the steps completed
122-
const completedNumSteps = opStatusResp.data.progressLogs.filter((log) => log.status === 'success').length
129+
const completedNumSteps = opStatusResp.data.progressLogs.filter((log: ProgressLog) => log.status === 'success').length
123130
progressBar.update(completedNumSteps)
124131
if (
125132
completedNumSteps === numSteps ||
@@ -170,7 +177,7 @@ export default class MissionctrlBrokerOpstatus extends ScCommand<typeof Missionc
170177
const opStatusResp = await conn.get<EventBrokerOperationApiResponse>(opStatusApiUrl)
171178
if (opStatusResp.data.progressLogs) {
172179
const numSteps = opStatusResp.data.progressLogs.length
173-
const completedNumSteps = opStatusResp.data.progressLogs.filter((log) => log.status === 'success').length
180+
const completedNumSteps = opStatusResp.data.progressLogs.filter((log: ProgressLog) => log.status === 'success').length
174181
// Update progress bar
175182
progressBar.setTotal(numSteps)
176183
progressBar.update(completedNumSteps)

src/commands/missionctrl/broker/state.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {printObjectAsKeyValueTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {printObjectAsKeyValueTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EventBrokerListApiResponse, EventBrokerRedundancyApiResponse} from '../../../types/broker.js'
56

67
export default class MissionctrlBrokerState extends ScCommand<typeof MissionctrlBrokerState> {
@@ -13,6 +14,7 @@ export default class MissionctrlBrokerState extends ScCommand<typeof Missionctrl
1314
static override examples = [
1415
'<%= config.bin %> <%= command.id %> --broker-id=MyBrokerServiceId',
1516
'<%= config.bin %> <%= command.id %> --name=MyBrokerName',
17+
'<%= config.bin %> <%= command.id %> --org=my-org --broker-id=MyBrokerServiceId',
1618
]
1719
static override flags = {
1820
'broker-id': Flags.string({
@@ -25,6 +27,10 @@ export default class MissionctrlBrokerState extends ScCommand<typeof Missionctrl
2527
description: 'Name of the event broker service.',
2628
exactlyOne: ['broker-id', 'name'],
2729
}),
30+
org: Flags.string({
31+
char: 'o',
32+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
33+
}),
2834
}
2935

3036
public async run(): Promise<EventBrokerRedundancyApiResponse> {
@@ -33,7 +39,7 @@ export default class MissionctrlBrokerState extends ScCommand<typeof Missionctrl
3339
const name = flags.name ?? ''
3440
let brokerId = flags['broker-id'] ?? ''
3541

36-
const conn = new ScConnection()
42+
const conn = await resolveOrgConnection(this, flags.org)
3743

3844
// API url
3945
let apiUrl: string = `/missionControl/eventBrokerServices`

src/commands/missionctrl/broker/update.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {printObjectAsKeyValueTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {printObjectAsKeyValueTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EventBrokerListApiResponse, EventBrokerOperationApiResponse} from '../../../types/broker.js'
56

67
export default class MissionctrlBrokerUpdate extends ScCommand<typeof MissionctrlBrokerUpdate> {
@@ -14,7 +15,7 @@ export default class MissionctrlBrokerUpdate extends ScCommand<typeof Missionctr
1415
static override examples = [
1516
'<%= config.bin %> <%= command.id %>',
1617
'<%= config.bin %> <%= command.id %> --broker-id <broker-id> --new-name <new-name>',
17-
'<%= config.bin %> <%= command.id %> --name <name> --new-name <new-name>',
18+
'<%= config.bin %> <%= command.id %> --org=my-org --name <name> --new-name <new-name>',
1819
]
1920
static override flags = {
2021
'broker-id': Flags.string({
@@ -34,6 +35,10 @@ export default class MissionctrlBrokerUpdate extends ScCommand<typeof Missionctr
3435
'new-name': Flags.string({
3536
description: 'New name of the event broker service. The new service name must be unique within an organization.',
3637
}),
38+
org: Flags.string({
39+
char: 'o',
40+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
41+
}),
3742
}
3843

3944
public async run(): Promise<EventBrokerOperationApiResponse> {
@@ -51,7 +56,7 @@ export default class MissionctrlBrokerUpdate extends ScCommand<typeof Missionctr
5156
...(newName && {name: newName}),
5257
}
5358

54-
const conn = new ScConnection()
59+
const conn = await resolveOrgConnection(this, flags.org)
5560

5661
// API url
5762
let apiUrl = `/missionControl/eventBrokerServices`

src/commands/platform/env/create.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {printObjectAsKeyValueTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {printObjectAsKeyValueTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EnvironmentApiResponse} from '../../../types/environment.js'
56

67
export default class PlatformEnvCreate extends ScCommand<typeof PlatformEnvCreate> {
@@ -9,7 +10,8 @@ export default class PlatformEnvCreate extends ScCommand<typeof PlatformEnvCreat
910
1011
Token Permissions: [ environments:edit ]`
1112
static override examples = [
12-
'<%= config.bin %> <%= command.id %> --name=MyEnvironment --description="My environment description" --isDefault --isProduction',
13+
'<%= config.bin %> <%= command.id %> --name=MyEnvironment',
14+
'<%= config.bin %> <%= command.id %> --org=my-org --name=MyEnvironment --description="My environment description" --isDefault --isProduction',
1315
]
1416
static override flags = {
1517
description: Flags.string({
@@ -30,6 +32,10 @@ export default class PlatformEnvCreate extends ScCommand<typeof PlatformEnvCreat
3032
description: 'Name of the environment to create.',
3133
required: true,
3234
}),
35+
org: Flags.string({
36+
char: 'o',
37+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
38+
}),
3339
}
3440

3541
public async run(): Promise<EnvironmentApiResponse> {
@@ -40,7 +46,7 @@ export default class PlatformEnvCreate extends ScCommand<typeof PlatformEnvCreat
4046
const isDefault = flags.isDefault ?? false
4147
const isProduction = flags.isProduction ?? false
4248

43-
const conn = new ScConnection()
49+
const conn = await resolveOrgConnection(this, flags.org)
4450

4551
// API url
4652
const apiUrl: string = `/platform/environments`

src/commands/platform/env/delete.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EnvironmentListApiResponse} from '../../../types/environment.js'
56

67
export default class PlatformEnvDelete extends ScCommand<typeof PlatformEnvDelete> {
@@ -11,6 +12,7 @@ export default class PlatformEnvDelete extends ScCommand<typeof PlatformEnvDelet
1112
static override examples = [
1213
'<%= config.bin %> <%= command.id %> --name=MyEnvName',
1314
'<%= config.bin %> <%= command.id %> --env-id=MyEnvId',
15+
'<%= config.bin %> <%= command.id %> --org=my-org --name=MyEnvName',
1416
]
1517
static override flags = {
1618
'env-id': Flags.string({
@@ -23,6 +25,10 @@ export default class PlatformEnvDelete extends ScCommand<typeof PlatformEnvDelet
2325
description: 'Name of the environment.',
2426
exactlyOne: ['env-id', 'name'],
2527
}),
28+
org: Flags.string({
29+
char: 'o',
30+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
31+
}),
2632
}
2733

2834
public async run(): Promise<{message: string}> {
@@ -31,7 +37,7 @@ export default class PlatformEnvDelete extends ScCommand<typeof PlatformEnvDelet
3137
const name = flags.name ?? ''
3238
const envId = flags['env-id'] ?? ''
3339

34-
const conn = new ScConnection()
40+
const conn = await resolveOrgConnection(this, flags.org)
3541

3642
// API url
3743
let apiUrl: string = `/platform/environments`

src/commands/platform/env/display.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {printObjectAsKeyValueTable, ScCommand, ScConnection} from '@dishantlangayan/sc-cli-core'
1+
import {printObjectAsKeyValueTable, ScCommand} from '@dishantlangayan/sc-cli-core'
22
import {Flags} from '@oclif/core'
33

4+
import {resolveOrgConnection} from '../../../lib/org-utils.js'
45
import {EnvironmentApiResponse, EnvironmentListApiResponse} from '../../../types/environment.js'
56

67
export default class PlatformEnvDisplay extends ScCommand<typeof PlatformEnvDisplay> {
@@ -13,6 +14,7 @@ export default class PlatformEnvDisplay extends ScCommand<typeof PlatformEnvDisp
1314
static override examples = [
1415
'<%= config.bin %> <%= command.id %> --name=MyEnvName',
1516
'<%= config.bin %> <%= command.id %> --env-id=MyEnvId',
17+
'<%= config.bin %> <%= command.id %> --org=my-org --env-id=MyEnvId',
1618
]
1719
static override flags = {
1820
'env-id': Flags.string({
@@ -25,6 +27,10 @@ export default class PlatformEnvDisplay extends ScCommand<typeof PlatformEnvDisp
2527
description: 'Name of the environment.',
2628
exactlyOne: ['env-id', 'name'],
2729
}),
30+
org: Flags.string({
31+
char: 'o',
32+
description: 'Organization ID or alias to use. If not specified, uses the default organization.',
33+
}),
2834
}
2935

3036
public async run(): Promise<EnvironmentApiResponse | EnvironmentListApiResponse> {
@@ -33,7 +39,7 @@ export default class PlatformEnvDisplay extends ScCommand<typeof PlatformEnvDisp
3339
const name = flags.name ?? ''
3440
const envId = flags['env-id'] ?? ''
3541

36-
const conn = new ScConnection()
42+
const conn = await resolveOrgConnection(this, flags.org)
3743

3844
// API url
3945
// If env name provided, get all environments matching provided name

0 commit comments

Comments
 (0)