diff --git a/tsp-typescript-client/fixtures/tsp-client/close-experiment-0.json b/tsp-typescript-client/fixtures/tsp-client/close-experiment-0.json new file mode 100644 index 0000000..087f624 --- /dev/null +++ b/tsp-typescript-client/fixtures/tsp-client/close-experiment-0.json @@ -0,0 +1,19 @@ +{ + "name": "kernel", + "UUID": "22222222-2222-2222-2222-222222222222", + "nbEvents": 0, + "start": 0, + "end": 0, + "indexingStatus": "CLOSED", + "traces": [ + { + "name": "kernel", + "path": "/path/kernel", + "UUID": "11111111-1111-1111-1111-111111111111", + "nbEvents": 0, + "start": 0, + "end": 0, + "indexingStatus": "CLOSED" + } + ] +} diff --git a/tsp-typescript-client/src/protocol/http-tsp-client.ts b/tsp-typescript-client/src/protocol/http-tsp-client.ts index 3233432..5d32760 100644 --- a/tsp-typescript-client/src/protocol/http-tsp-client.ts +++ b/tsp-typescript-client/src/protocol/http-tsp-client.ts @@ -142,6 +142,18 @@ export class HttpTspClient implements ITspClient { return RestClient.put(url, parameters, Experiment); } + /** + * Close an experiment + * @param expUUID Experiment UUID to close + * @returns The closed experiment + */ + closeExperiment( + expUUID: string + ): Promise> { + const url = this.baseUrl + "/experiments/" + expUUID + ":close"; + return RestClient.put(url, new Query({}), Experiment); + } + /** * Delete an experiment on the server * @param expUUID Experiment UUID to delete diff --git a/tsp-typescript-client/src/protocol/tsp-client.test.ts b/tsp-typescript-client/src/protocol/tsp-client.test.ts index 78dec89..5992192 100644 --- a/tsp-typescript-client/src/protocol/tsp-client.test.ts +++ b/tsp-typescript-client/src/protocol/tsp-client.test.ts @@ -108,6 +108,14 @@ describe('HttpTspClient Deserialization', () => { expect(typeof experiment.nbEvents).toEqual('number'); }); + it('deleteExperiment', async () => { + httpRequestMock.mockReturnValueOnce(fixtures.asResponse('close-experiment-0.json')); + const response = await client.closeExperiment('not-relevant'); + const experiment = response.getModel()!; + + expect(experiment.indexingStatus).toEqual('CLOSED'); + }); + it('deleteTrace', async () => { httpRequestMock.mockReturnValueOnce(fixtures.asResponse('delete-trace-0.json')); const response = await client.deleteTrace('not-relevant'); diff --git a/tsp-typescript-client/src/protocol/tsp-client.ts b/tsp-typescript-client/src/protocol/tsp-client.ts index e35900f..0e818d7 100644 --- a/tsp-typescript-client/src/protocol/tsp-client.ts +++ b/tsp-typescript-client/src/protocol/tsp-client.ts @@ -94,6 +94,15 @@ export interface ITspClient { parameters: Query ): Promise>; + /** + * Close an experiment + * @param expUUID Experiment UUID to close + * @returns The closed experiment + */ + closeExperiment( + expUUID: string + ): Promise>; + /** * Delete an experiment on the server * @param expUUID Experiment UUID to delete