-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDataApi.java
More file actions
executable file
·48 lines (41 loc) · 1.2 KB
/
DataApi.java
File metadata and controls
executable file
·48 lines (41 loc) · 1.2 KB
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
package com.coscale.sdk.client.data;
import java.io.IOException;
import com.coscale.sdk.client.ApiClient;
import com.coscale.sdk.client.commons.Msg;
import com.fasterxml.jackson.core.type.TypeReference;
/**
* CoScale API client used to insert data.
*
* @author cristi
*
*/
public class DataApi {
/** ApiClient used to make HTTP requests */
private final ApiClient api;
/**
* DataApi contructor.
*
* @param api
* ApiClient.
*/
public DataApi(ApiClient api) {
this.api = api;
}
/**
* Insert data into the data-store
*
* @param data
* @return Msg containing the api response.
* @throws IOException
*/
public Msg insert(String subjectId, DataInsert data) throws IOException {
return api.callWithAuth("POST", "/data/" + subjectId + '/', data, new MsgTypeReference());
}
/**
* Copied from the Intellij code analysis:
* A static inner class does not keep an implicit reference to its enclosing instance.
* This prevents a common cause of memory leaks and uses less memory per instance of the class.
*/
private static class MsgTypeReference extends TypeReference<Msg> {
}
}