Skip to content

Commit 8e9cba0

Browse files
authored
DATA 4228: Update SDKs and CLI (#571)
1 parent 867c57a commit 8e9cba0

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/app/data-client.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
TabularDataByFilterResponse,
4747
TabularDataByMQLResponse,
4848
TabularDataBySQLResponse,
49+
TabularDataSourceType,
4950
TagsByFilterRequest,
5051
TagsByFilterResponse,
5152
TagsFilter,
@@ -1427,17 +1428,21 @@ describe('DataPipelineClient tests', () => {
14271428
const pipelineName = 'testPipeline';
14281429
const mqlQuery = [{ $match: { component_name: 'sensor-1' } }];
14291430
const schedule = '0 0 * * *';
1431+
const dataSourceTypeStandard = TabularDataSourceType.STANDARD;
1432+
const dataSourceTypeHotStorage = TabularDataSourceType.HOT_STORAGE;
14301433

14311434
describe('listDataPipelines tests', () => {
14321435
const pipeline1 = new DataPipeline({
14331436
id: 'pipeline1',
14341437
name: 'pipeline1',
14351438
organizationId: 'org1',
1439+
dataSourceType: dataSourceTypeStandard,
14361440
});
14371441
const pipeline2 = new DataPipeline({
14381442
id: 'pipeline2',
14391443
name: 'pipeline2',
14401444
organizationId: 'org2',
1445+
dataSourceType: dataSourceTypeHotStorage,
14411446
});
14421447
const pipelines = [pipeline1, pipeline2];
14431448

@@ -1471,6 +1476,7 @@ describe('DataPipelineClient tests', () => {
14711476
id: pipelineId,
14721477
name: pipelineName,
14731478
organizationId,
1479+
dataSourceType: dataSourceTypeStandard,
14741480
});
14751481

14761482
let capReq: GetDataPipelineRequest;
@@ -1532,6 +1538,27 @@ describe('DataPipelineClient tests', () => {
15321538
name: pipelineName,
15331539
mqlBinary: mqlQuery.map((value) => BSON.serialize(value)),
15341540
schedule,
1541+
dataSourceType: dataSourceTypeStandard,
1542+
});
1543+
1544+
const response = await subject().createDataPipeline(
1545+
organizationId,
1546+
pipelineName,
1547+
mqlQuery,
1548+
schedule,
1549+
dataSourceTypeStandard
1550+
);
1551+
expect(capReq).toStrictEqual(expectedRequest);
1552+
expect(response).toEqual(pipelineId);
1553+
});
1554+
1555+
it('create data pipeline with optional dataSourceType', async () => {
1556+
const expectedRequest = new CreateDataPipelineRequest({
1557+
organizationId,
1558+
name: pipelineName,
1559+
mqlBinary: mqlQuery.map((value) => BSON.serialize(value)),
1560+
schedule,
1561+
dataSourceType: dataSourceTypeStandard,
15351562
});
15361563

15371564
const response = await subject().createDataPipeline(

src/app/data-client.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,24 +1409,30 @@ export class DataClient {
14091409
* @param name The name of the data pipeline
14101410
* @param query The MQL query to run as a list of BSON documents
14111411
* @param schedule The schedule to run the query on (cron expression)
1412+
* @param dataSourceType The type of data source to use for the data pipeline
14121413
* @returns The ID of the created data pipeline
14131414
*/
14141415
async createDataPipeline(
14151416
organizationId: string,
14161417
name: string,
14171418
query: Uint8Array[] | Record<string, Date | JsonValue>[],
1418-
schedule: string
1419+
schedule: string,
1420+
dataSourceType?: TabularDataSourceType
14191421
): Promise<string> {
14201422
const mqlBinary: Uint8Array[] =
14211423
query[0] instanceof Uint8Array
14221424
? (query as Uint8Array[])
14231425
: query.map((value) => BSON.serialize(value));
14241426

1427+
const inputDataSourceType =
1428+
dataSourceType ?? TabularDataSourceType.STANDARD;
1429+
14251430
const resp = await this.dataPipelinesClient.createDataPipeline({
14261431
organizationId,
14271432
name,
14281433
mqlBinary,
14291434
schedule,
1435+
dataSourceType: inputDataSourceType,
14301436
});
14311437
return resp.id;
14321438
}

0 commit comments

Comments
 (0)