-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add simulation run data API (#1098)
* feat: add simulation run data API * fix: fix optional types
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/alpha/src/__tests__/api/simulationRunDataApi.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 Cognite AS | ||
import CogniteClientAlpha from '../../cogniteClient'; | ||
import { setupLoggedInClient } from '../testUtils'; | ||
|
||
const SHOULD_RUN_TESTS = process.env.RUN_SDK_SIMINT_TESTS == 'true'; | ||
|
||
const describeIf = SHOULD_RUN_TESTS ? describe : describe.skip; | ||
|
||
describeIf('simulation run data api', () => { | ||
const client: CogniteClientAlpha = setupLoggedInClient(); | ||
|
||
test('list simulation run data', async () => { | ||
const runs = await client.simulators.listRuns({ | ||
filter: { | ||
simulatorName: 'DWSIM', | ||
status: 'success', | ||
}, | ||
}); | ||
|
||
const runId = runs.items[0].id; | ||
|
||
const runData = await client.simulators.listRunData([ | ||
{ | ||
runId, | ||
}, | ||
]); | ||
|
||
expect(runData).toBeDefined(); | ||
expect(runData.length).toBeGreaterThan(0); | ||
|
||
const item = runData[0]; | ||
|
||
expect(item.runId).toBe(runId); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2023 Cognite AS | ||
|
||
import { BaseResourceAPI, CDFHttpClient, MetadataMap } from '@cognite/sdk-core'; | ||
import { SimulationRunData, SimulationRunId } from '../../types'; | ||
|
||
export class SimulationRunDataAPI extends BaseResourceAPI<SimulationRunData> { | ||
constructor(...args: [string, CDFHttpClient, MetadataMap]) { | ||
super(...args); | ||
} | ||
|
||
public retrieve = async (ids: SimulationRunId[]) => { | ||
const path = this.url('simulators/runs/data/list'); | ||
|
||
return this.retrieveEndpoint(ids, {}, path); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters