-
Notifications
You must be signed in to change notification settings - Fork 7
/
featureTypeAPI.ts
89 lines (84 loc) · 2.7 KB
/
featureTypeAPI.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import {
BaseResourceAPI,
CursorAndAsyncIterator,
ExternalId,
} from '@cognite/sdk-core';
import {
FeatureType,
GeospatialCreateFeatureType,
GeospatialUpdateFeatureType,
GeospatialRecursiveDelete,
} from './types';
export class FeatureTypeAPI extends BaseResourceAPI<FeatureType> {
/**
* [Create feature types](https://docs.cognite.com/api/v1/#operation/createFeatureTypes)
*
* ```js
* const featureTypes = [
* {
* externalId: 'ocean_temperature',
* properties: { temperature: { type: 'DOUBLE' as const }, location: { type: 'POINT' as const, srid: 4326 } } ,
* searchSpec: { location_idx: { properties : ['location'] } }
* }
* ];
* const createdFeatureTypes = await client.geospatial.featureType.create(featureTypes);
* ```
*/
public create = (
featureTypes: GeospatialCreateFeatureType[]
): Promise<FeatureType[]> => {
return this.createEndpoint<GeospatialCreateFeatureType>(featureTypes);
};
/**
* [Retrieve feature types](https://docs.cognite.com/api/v1/#operation/getFeatureTypesByIds)
*
* ```js
* const retrievedFeatureTypes = await client.geospatial.featureType.retrieve([ { externalId: 'ocean_temperature' } ]);
* ```
*/
public retrieve = (externalIds: ExternalId[]): Promise<FeatureType[]> => {
return this.retrieveEndpoint(externalIds);
};
/**
* [List feature types](https://docs.cognite.com/api/v1/#operation/listFeatureTypes)
*
* ```js
* const allFeatureTypes = await client.geospatial.featureType.list();
* ```
*/
public list = (): CursorAndAsyncIterator<FeatureType> => {
return this.listEndpoint(this.callListEndpointWithPost);
};
/**
* [Delete feature types](https://docs.cognite.com/api/v1/#operation/GeospatialDeleteFeatureTypes)
*
* ```js
* await client.geospatial.featureType.delete([{ externalId: 'ocean_temperature'}], { recursive : true });
* ```
*/
public delete = (
externalIds: ExternalId[],
params: GeospatialRecursiveDelete = {}
) => {
return this.deleteEndpoint(externalIds, params);
};
/**
* [Update feature types](https://docs.cognite.com/api/v1/#operation/updateFeatureTypes)
*
* ```js
* const featureTypesToUpdate = [
* {
* externalId: 'ocean_temperature',
* update: {
* properties: { add: { depth: { type: 'DOUBLE'} }, remove: ['temperature'] },
* searchSpec: { add: { depth_idx: { properties: ['depth'] } } }
* }
* }
* ];
* const updatedFeatureTypes = await client.geospatial.featureType.update(featureTypesToUpdate);
* ```
*/
public update = (changes: GeospatialUpdateFeatureType[]) => {
return this.updateEndpoint<GeospatialUpdateFeatureType>(changes);
};
}