/
v1.js
76 lines (68 loc) · 3.29 KB
/
v1.js
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
const OsduBaseService = require('../base');
/**
* Class that provides named access to OSDU Dataset endpoints
* - [Service Documentation]{@link https://community.opengroup.org/osdu/platform/system/dataset/-/blob/master/docs/dataset.swagger.yaml}
* - [API Documentation]{@link https://community.opengroup.org/osdu/platform/system/dataset/-/blob/master/docs/dataset.swagger.yaml}
* @class
* @category Services
* @subcategory Dataset
*/
class OsduV1DatasetService extends OsduBaseService {
/**
* @constructor
* @param {BaseOsduClient} osdu_client - An implementation of the OSDU client class to broker communication with the OSDU API
* @param {string} data_partition - The data partition against which requests will be made
*/
constructor(osdu_client, data_partition) {
super(osdu_client, data_partition);
}
/**
* Get dataset registry object for the given dataset registry ID
* @param {string} registryId - Identifier for the dataset registry you wish to retrieve
* @returns {Object} The API Response
*/
async getDatasetRegistry(registryId) {
return await this._client.get(`/api/dataset/v1/getDatasetRegistry?id=${registryId}`, this._dataPartition);
}
/**
* Get dataset registry objects for the given list dataset registry IDs
* @param {string[]} registryIds - Identifiers for the dataset registries you wish to retrieve
* @returns {Object} The API Response
*/
async getDatasetRegistries(registryIds) {
return await this._client.post(`/api/dataset/v1/getDatasetRegistry`, { datasetRegistryIds: registryIds }, this._dataPartition);
}
/**
* Register a list of datasets
* @param {object[]} datasetRegistries - List of dataset registry objects to register
* @returns {Object} The API Response
*/
async registerDatasets(datasetRegistries) {
return await this._client.put(`/api/dataset/v1/registerDataset`, { datasetRegistries }, this._dataPartition);
}
/**
* Get instructions on how to store a given dataset sub type
* @param {string} kindSubType - Identifier for the kind of dataset you wish to store source data for
* @returns {Object} The API Response
*/
async getStorageInstructions(kindSubType) {
return await this._client.get(`/api/dataset/v1/getStorageInstructions?kindSubType=${kindSubType}`, this._dataPartition);
}
/**
* Get instructions on how to retrieve a given dataset registry
* @param {string} registryId - Identifier for the dataset registry you wish to retrieve source data for
* @returns {Object} The API Response
*/
async getRetrievalInstructions(registryId) {
return await this._client.get(`/api/dataset/v1/getRetrievalInstructions?datasetRegistryId=${registryId}`, this._dataPartition);
}
/**
* Get instructions on how to retrieve a given dataset registry
* @param {string[]} registryIds - Identifiers for the dataset registries you wish to retrieve source data for
* @returns {Object} The API Response
*/
async getMultipleRetrievalInstructions(registryIds) {
return await this._client.post(`/api/dataset/v1/getRetrievalInstructions`, { datasetRegistryIds: registryIds }, this._dataPartition);
}
}
module.exports = OsduV1DatasetService;