Skip to content

Commit d19fdba

Browse files
authored
feat(shell-api): add sp.listWorkspaceDefaults command MONGOSH-2949 (#2558)
1 parent d23f69f commit d19fdba

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

packages/i18n/src/locales/en_US.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,6 +2894,10 @@ const translations: Catalog = {
28942894
description:
28952895
'Show a list of all the named connections for this instance from the Connection Registry.',
28962896
},
2897+
listWorkspaceDefaults: {
2898+
description:
2899+
'Show the default tier and maxTierSize for the stream processor workspace.',
2900+
},
28972901
},
28982902
},
28992903
},

packages/shell-api/src/streams.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,22 @@ describe('Streams', function () {
312312
).to.be.true;
313313
});
314314
});
315+
316+
describe('listWorkspaceDefaults', function () {
317+
it('returns tier and maxTierSize', async function () {
318+
const runCmdStub = sinon
319+
.stub(mongo._serviceProvider, 'runCommand')
320+
.resolves({ ok: 1, defaultTierSize: 'SP2', maxTierSize: 'SP30' });
321+
322+
const result = await streams.listWorkspaceDefaults();
323+
expect(result).to.eql({
324+
ok: 1,
325+
defaultTierSize: 'SP2',
326+
maxTierSize: 'SP30',
327+
});
328+
329+
const cmd = { listWorkspaceDefaults: 1 };
330+
expect(runCmdStub.calledOnceWithExactly('admin', cmd, {})).to.be.true;
331+
});
332+
});
315333
});

packages/shell-api/src/streams.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import type Mongo from './mongo';
1313
import type { GenericDatabaseSchema, GenericServerSideSchema } from './helpers';
1414
import type { MQLPipeline } from './mql-types';
1515

16+
type WorkspaceDefaults = {
17+
defaultTierSize: string;
18+
maxTierSize: string;
19+
};
20+
1621
@shellApiClassDefault
1722
export class Streams<
1823
M extends GenericServerSideSchema = GenericServerSideSchema,
@@ -162,6 +167,13 @@ export class Streams<
162167
});
163168
}
164169

170+
@returnsPromise
171+
async listWorkspaceDefaults(): Promise<WorkspaceDefaults> {
172+
return (await this._runStreamCommand({
173+
listWorkspaceDefaults: 1,
174+
})) as WorkspaceDefaults;
175+
}
176+
165177
async _runStreamCommand(cmd: Document, options: Document = {}) {
166178
return this._mongo._serviceProvider.runCommand(ADMIN_DB, cmd, options); // run cmd
167179
}

0 commit comments

Comments
 (0)