-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcogniteClient.ts
68 lines (57 loc) · 1.93 KB
/
cogniteClient.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2020 Cognite AS
import { CogniteClient as CogniteClientStable } from '@cognite/sdk';
import { accessApi } from '@cognite/sdk-core';
import { version } from '../package.json';
import { AlertsAPI } from './api/alerts/alertsApi';
import { DataPointsAPI } from './api/dataPoints/dataPointsApi';
import { MonitoringTasksAPI } from './api/monitoringTasks/monitoringTasksApi';
class CogniteClientCleaned extends CogniteClientStable {
// Remove type restrictions
}
/**
* SDK client (beta)
*
* For smooth transition between stable sdk and beta, you may create an alias
* `"@cognite/sdk": "@cognite/sdk-beta@^<version>"` in `package.json`
* The beta SDK exports the client with the same name as stable, meaning you don't need to change any imports.
* ```js
* import { CogniteClient } from '@cognite/sdk';
*
* const client = new CogniteClient({ appId: 'YOUR APPLICATION NAME' });
*
* // can also specify a base URL
* const client = new CogniteClient({ ..., baseUrl: 'https://greenfield.cognitedata.com' });
* ```
*
* @param options Client options
*/
export default class CogniteClient extends CogniteClientCleaned {
private alertsApi?: AlertsAPI;
private monitoringTasksApi?: MonitoringTasksAPI;
public get alerts() {
return accessApi(this.alertsApi);
}
public get files() {
return accessApi(this.filesApi);
}
public get monitoringTasks() {
return accessApi(this.monitoringTasksApi);
}
public get datapoints() {
return accessApi(this.dataPointsApi);
}
protected dataPointsApi?: DataPointsAPI;
protected get version() {
return `${version}-beta`;
}
protected initAPIs() {
super.initAPIs();
this.httpClient.setDefaultHeader('cdf-version', 'beta');
this.alertsApi = this.apiFactory(AlertsAPI, 'alerts');
this.monitoringTasksApi = this.apiFactory(
MonitoringTasksAPI,
'monitoringtasks'
);
this.dataPointsApi = this.apiFactory(DataPointsAPI, 'timeseries/data');
}
}