@algolia/ingestion 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builds/browser.d.ts +6 -0
- package/dist/builds/browser.d.ts.map +1 -0
- package/dist/builds/node.d.ts +6 -0
- package/dist/builds/node.d.ts.map +1 -0
- package/dist/ingestion.cjs.js +815 -0
- package/dist/ingestion.esm.browser.js +1450 -0
- package/dist/ingestion.esm.node.js +810 -0
- package/dist/ingestion.umd.js +2 -0
- package/dist/model/actionType.d.ts +2 -0
- package/dist/model/actionType.d.ts.map +1 -0
- package/dist/model/authAPIKey.d.ts +4 -0
- package/dist/model/authAPIKey.d.ts.map +1 -0
- package/dist/model/authAlgolia.d.ts +5 -0
- package/dist/model/authAlgolia.d.ts.map +1 -0
- package/dist/model/authBasic.d.ts +5 -0
- package/dist/model/authBasic.d.ts.map +1 -0
- package/dist/model/authGoogleServiceAccount.d.ts +5 -0
- package/dist/model/authGoogleServiceAccount.d.ts.map +1 -0
- package/dist/model/authInput.d.ts +7 -0
- package/dist/model/authInput.d.ts.map +1 -0
- package/dist/model/authOAuth.d.ts +7 -0
- package/dist/model/authOAuth.d.ts.map +1 -0
- package/dist/model/authentication.d.ts +19 -0
- package/dist/model/authentication.d.ts.map +1 -0
- package/dist/model/authenticationCreate.d.ts +10 -0
- package/dist/model/authenticationCreate.d.ts.map +1 -0
- package/dist/model/authenticationCreateResponse.d.ts +9 -0
- package/dist/model/authenticationCreateResponse.d.ts.map +1 -0
- package/dist/model/authenticationType.d.ts +2 -0
- package/dist/model/authenticationType.d.ts.map +1 -0
- package/dist/model/authenticationUpdate.d.ts +10 -0
- package/dist/model/authenticationUpdate.d.ts.map +1 -0
- package/dist/model/authenticationUpdateResponse.d.ts +9 -0
- package/dist/model/authenticationUpdateResponse.d.ts.map +1 -0
- package/dist/model/clientMethodProps.d.ts +265 -0
- package/dist/model/clientMethodProps.d.ts.map +1 -0
- package/dist/model/deleteResponse.d.ts +7 -0
- package/dist/model/deleteResponse.d.ts.map +1 -0
- package/dist/model/destination.d.ts +18 -0
- package/dist/model/destination.d.ts.map +1 -0
- package/dist/model/destinationCreate.d.ts +9 -0
- package/dist/model/destinationCreate.d.ts.map +1 -0
- package/dist/model/destinationCreateResponse.d.ts +9 -0
- package/dist/model/destinationCreateResponse.d.ts.map +1 -0
- package/dist/model/destinationIndexName.d.ts +4 -0
- package/dist/model/destinationIndexName.d.ts.map +1 -0
- package/dist/model/destinationIndexPrefix.d.ts +4 -0
- package/dist/model/destinationIndexPrefix.d.ts.map +1 -0
- package/dist/model/destinationInput.d.ts +4 -0
- package/dist/model/destinationInput.d.ts.map +1 -0
- package/dist/model/destinationType.d.ts +2 -0
- package/dist/model/destinationType.d.ts.map +1 -0
- package/dist/model/destinationUpdate.d.ts +9 -0
- package/dist/model/destinationUpdate.d.ts.map +1 -0
- package/dist/model/destinationUpdateResponse.d.ts +9 -0
- package/dist/model/destinationUpdateResponse.d.ts.map +1 -0
- package/dist/model/errorBase.d.ts +7 -0
- package/dist/model/errorBase.d.ts.map +1 -0
- package/dist/model/event.d.ts +15 -0
- package/dist/model/event.d.ts.map +1 -0
- package/dist/model/eventStatus.d.ts +2 -0
- package/dist/model/eventStatus.d.ts.map +1 -0
- package/dist/model/eventType.d.ts +2 -0
- package/dist/model/eventType.d.ts.map +1 -0
- package/dist/model/index.d.ts +59 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/listAuthenticationsResponse.d.ts +7 -0
- package/dist/model/listAuthenticationsResponse.d.ts.map +1 -0
- package/dist/model/listDestinationsResponse.d.ts +7 -0
- package/dist/model/listDestinationsResponse.d.ts.map +1 -0
- package/dist/model/listEventsResponse.d.ts +7 -0
- package/dist/model/listEventsResponse.d.ts.map +1 -0
- package/dist/model/listSourcesResponse.d.ts +7 -0
- package/dist/model/listSourcesResponse.d.ts.map +1 -0
- package/dist/model/listTasksResponse.d.ts +7 -0
- package/dist/model/listTasksResponse.d.ts.map +1 -0
- package/dist/model/pagination.d.ts +7 -0
- package/dist/model/pagination.d.ts.map +1 -0
- package/dist/model/platformType.d.ts +2 -0
- package/dist/model/platformType.d.ts.map +1 -0
- package/dist/model/run.d.ts +30 -0
- package/dist/model/run.d.ts.map +1 -0
- package/dist/model/runListResponse.d.ts +7 -0
- package/dist/model/runListResponse.d.ts.map +1 -0
- package/dist/model/runOutcome.d.ts +2 -0
- package/dist/model/runOutcome.d.ts.map +1 -0
- package/dist/model/runProgress.d.ts +5 -0
- package/dist/model/runProgress.d.ts.map +1 -0
- package/dist/model/runResponse.d.ts +8 -0
- package/dist/model/runResponse.d.ts.map +1 -0
- package/dist/model/runStatus.d.ts +2 -0
- package/dist/model/runStatus.d.ts.map +1 -0
- package/dist/model/runType.d.ts +2 -0
- package/dist/model/runType.d.ts.map +1 -0
- package/dist/model/source.d.ts +18 -0
- package/dist/model/source.d.ts.map +1 -0
- package/dist/model/sourceBigCommerce.d.ts +4 -0
- package/dist/model/sourceBigCommerce.d.ts.map +1 -0
- package/dist/model/sourceCommercetools.d.ts +6 -0
- package/dist/model/sourceCommercetools.d.ts.map +1 -0
- package/dist/model/sourceCreate.d.ts +9 -0
- package/dist/model/sourceCreate.d.ts.map +1 -0
- package/dist/model/sourceCreateResponse.d.ts +9 -0
- package/dist/model/sourceCreateResponse.d.ts.map +1 -0
- package/dist/model/sourceInput.d.ts +4 -0
- package/dist/model/sourceInput.d.ts.map +1 -0
- package/dist/model/sourceType.d.ts +2 -0
- package/dist/model/sourceType.d.ts.map +1 -0
- package/dist/model/sourceUpdate.d.ts +9 -0
- package/dist/model/sourceUpdate.d.ts.map +1 -0
- package/dist/model/sourceUpdateResponse.d.ts +9 -0
- package/dist/model/sourceUpdateResponse.d.ts.map +1 -0
- package/dist/model/task.d.ts +21 -0
- package/dist/model/task.d.ts.map +1 -0
- package/dist/model/taskCreate.d.ts +10 -0
- package/dist/model/taskCreate.d.ts.map +1 -0
- package/dist/model/taskCreateResponse.d.ts +8 -0
- package/dist/model/taskCreateResponse.d.ts.map +1 -0
- package/dist/model/taskUpdate.d.ts +7 -0
- package/dist/model/taskUpdate.d.ts.map +1 -0
- package/dist/model/taskUpdateResponse.d.ts +8 -0
- package/dist/model/taskUpdateResponse.d.ts.map +1 -0
- package/dist/model/trigger.d.ts +6 -0
- package/dist/model/trigger.d.ts.map +1 -0
- package/dist/model/triggerType.d.ts +2 -0
- package/dist/model/triggerType.d.ts.map +1 -0
- package/dist/src/ingestionClient.d.ts +322 -0
- package/dist/src/ingestionClient.d.ts.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/model/actionType.ts +3 -0
- package/model/authAPIKey.ts +5 -0
- package/model/authAlgolia.ts +7 -0
- package/model/authBasic.ts +7 -0
- package/model/authGoogleServiceAccount.ts +7 -0
- package/model/authInput.ts +14 -0
- package/model/authOAuth.ts +11 -0
- package/model/authentication.ts +27 -0
- package/model/authenticationCreate.ts +15 -0
- package/model/authenticationCreateResponse.ts +12 -0
- package/model/authenticationType.ts +8 -0
- package/model/authenticationUpdate.ts +15 -0
- package/model/authenticationUpdateResponse.ts +12 -0
- package/model/clientMethodProps.ts +290 -0
- package/model/deleteResponse.ts +8 -0
- package/model/destination.ts +26 -0
- package/model/destinationCreate.ts +14 -0
- package/model/destinationCreateResponse.ts +12 -0
- package/model/destinationIndexName.ts +5 -0
- package/model/destinationIndexPrefix.ts +5 -0
- package/model/destinationInput.ts +6 -0
- package/model/destinationType.ts +3 -0
- package/model/destinationUpdate.ts +14 -0
- package/model/destinationUpdateResponse.ts +12 -0
- package/model/errorBase.ts +8 -0
- package/model/event.ts +23 -0
- package/model/eventStatus.ts +8 -0
- package/model/eventType.ts +3 -0
- package/model/index.ts +60 -0
- package/model/listAuthenticationsResponse.ts +10 -0
- package/model/listDestinationsResponse.ts +10 -0
- package/model/listEventsResponse.ts +10 -0
- package/model/listSourcesResponse.ts +10 -0
- package/model/listTasksResponse.ts +10 -0
- package/model/pagination.ts +11 -0
- package/model/platformType.ts +3 -0
- package/model/run.ts +42 -0
- package/model/runListResponse.ts +10 -0
- package/model/runOutcome.ts +3 -0
- package/model/runProgress.ts +7 -0
- package/model/runResponse.ts +10 -0
- package/model/runStatus.ts +3 -0
- package/model/runType.ts +3 -0
- package/model/source.ts +26 -0
- package/model/sourceBigCommerce.ts +5 -0
- package/model/sourceCommercetools.ts +9 -0
- package/model/sourceCreate.ts +14 -0
- package/model/sourceCreateResponse.ts +12 -0
- package/model/sourceInput.ts +6 -0
- package/model/sourceType.ts +3 -0
- package/model/sourceUpdate.ts +14 -0
- package/model/sourceUpdateResponse.ts +12 -0
- package/model/task.ts +32 -0
- package/model/taskCreate.ts +16 -0
- package/model/taskCreateResponse.ts +10 -0
- package/model/taskUpdate.ts +11 -0
- package/model/taskUpdateResponse.ts +10 -0
- package/model/trigger.ts +9 -0
- package/model/triggerType.ts +3 -0
- package/package.json +53 -0
|
@@ -0,0 +1,1450 @@
|
|
|
1
|
+
function createAuth(appId, apiKey, authMode = 'WithinHeaders') {
|
|
2
|
+
const credentials = {
|
|
3
|
+
'x-algolia-api-key': apiKey,
|
|
4
|
+
'x-algolia-application-id': appId
|
|
5
|
+
};
|
|
6
|
+
return {
|
|
7
|
+
headers() {
|
|
8
|
+
return authMode === 'WithinHeaders' ? credentials : {};
|
|
9
|
+
},
|
|
10
|
+
queryParameters() {
|
|
11
|
+
return authMode === 'WithinQueryParameters' ? credentials : {};
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createBrowserLocalStorageCache(options) {
|
|
17
|
+
let storage;
|
|
18
|
+
// We've changed the namespace to avoid conflicts with v4, as this version is a huge breaking change
|
|
19
|
+
const namespaceKey = `algolia-client-js-${options.key}`;
|
|
20
|
+
function getStorage() {
|
|
21
|
+
if (storage === undefined) {
|
|
22
|
+
storage = options.localStorage || window.localStorage;
|
|
23
|
+
}
|
|
24
|
+
return storage;
|
|
25
|
+
}
|
|
26
|
+
function getNamespace() {
|
|
27
|
+
return JSON.parse(getStorage().getItem(namespaceKey) || '{}');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
get(key, defaultValue, events = {
|
|
31
|
+
miss: () => Promise.resolve()
|
|
32
|
+
}) {
|
|
33
|
+
return Promise.resolve().then(() => {
|
|
34
|
+
const keyAsString = JSON.stringify(key);
|
|
35
|
+
const value = getNamespace()[keyAsString];
|
|
36
|
+
return Promise.all([value || defaultValue(), value !== undefined]);
|
|
37
|
+
}).then(([value, exists]) => {
|
|
38
|
+
return Promise.all([value, exists || events.miss(value)]);
|
|
39
|
+
}).then(([value]) => value);
|
|
40
|
+
},
|
|
41
|
+
set(key, value) {
|
|
42
|
+
return Promise.resolve().then(() => {
|
|
43
|
+
const namespace = getNamespace();
|
|
44
|
+
namespace[JSON.stringify(key)] = value;
|
|
45
|
+
getStorage().setItem(namespaceKey, JSON.stringify(namespace));
|
|
46
|
+
return value;
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
delete(key) {
|
|
50
|
+
return Promise.resolve().then(() => {
|
|
51
|
+
const namespace = getNamespace();
|
|
52
|
+
delete namespace[JSON.stringify(key)];
|
|
53
|
+
getStorage().setItem(namespaceKey, JSON.stringify(namespace));
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
clear() {
|
|
57
|
+
return Promise.resolve().then(() => {
|
|
58
|
+
getStorage().removeItem(namespaceKey);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function createNullCache() {
|
|
65
|
+
return {
|
|
66
|
+
get(_key, defaultValue, events = {
|
|
67
|
+
miss: () => Promise.resolve()
|
|
68
|
+
}) {
|
|
69
|
+
const value = defaultValue();
|
|
70
|
+
return value.then(result => Promise.all([result, events.miss(result)])).then(([result]) => result);
|
|
71
|
+
},
|
|
72
|
+
set(_key, value) {
|
|
73
|
+
return Promise.resolve(value);
|
|
74
|
+
},
|
|
75
|
+
delete(_key) {
|
|
76
|
+
return Promise.resolve();
|
|
77
|
+
},
|
|
78
|
+
clear() {
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function createFallbackableCache(options) {
|
|
85
|
+
const caches = [...options.caches];
|
|
86
|
+
const current = caches.shift();
|
|
87
|
+
if (current === undefined) {
|
|
88
|
+
return createNullCache();
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
get(key, defaultValue, events = {
|
|
92
|
+
miss: () => Promise.resolve()
|
|
93
|
+
}) {
|
|
94
|
+
return current.get(key, defaultValue, events).catch(() => {
|
|
95
|
+
return createFallbackableCache({
|
|
96
|
+
caches
|
|
97
|
+
}).get(key, defaultValue, events);
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
set(key, value) {
|
|
101
|
+
return current.set(key, value).catch(() => {
|
|
102
|
+
return createFallbackableCache({
|
|
103
|
+
caches
|
|
104
|
+
}).set(key, value);
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
delete(key) {
|
|
108
|
+
return current.delete(key).catch(() => {
|
|
109
|
+
return createFallbackableCache({
|
|
110
|
+
caches
|
|
111
|
+
}).delete(key);
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
clear() {
|
|
115
|
+
return current.clear().catch(() => {
|
|
116
|
+
return createFallbackableCache({
|
|
117
|
+
caches
|
|
118
|
+
}).clear();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function createMemoryCache(options = {
|
|
125
|
+
serializable: true
|
|
126
|
+
}) {
|
|
127
|
+
let cache = {};
|
|
128
|
+
return {
|
|
129
|
+
get(key, defaultValue, events = {
|
|
130
|
+
miss: () => Promise.resolve()
|
|
131
|
+
}) {
|
|
132
|
+
const keyAsString = JSON.stringify(key);
|
|
133
|
+
if (keyAsString in cache) {
|
|
134
|
+
return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]);
|
|
135
|
+
}
|
|
136
|
+
const promise = defaultValue();
|
|
137
|
+
return promise.then(value => events.miss(value)).then(() => promise);
|
|
138
|
+
},
|
|
139
|
+
set(key, value) {
|
|
140
|
+
cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value;
|
|
141
|
+
return Promise.resolve(value);
|
|
142
|
+
},
|
|
143
|
+
delete(key) {
|
|
144
|
+
delete cache[JSON.stringify(key)];
|
|
145
|
+
return Promise.resolve();
|
|
146
|
+
},
|
|
147
|
+
clear() {
|
|
148
|
+
cache = {};
|
|
149
|
+
return Promise.resolve();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// By default, API Clients at Algolia have expiration delay of 5 mins.
|
|
155
|
+
// In the JavaScript client, we have 2 mins.
|
|
156
|
+
const EXPIRATION_DELAY = 2 * 60 * 1000;
|
|
157
|
+
function createStatefulHost(host, status = 'up') {
|
|
158
|
+
const lastUpdate = Date.now();
|
|
159
|
+
function isUp() {
|
|
160
|
+
return status === 'up' || Date.now() - lastUpdate > EXPIRATION_DELAY;
|
|
161
|
+
}
|
|
162
|
+
function isTimedOut() {
|
|
163
|
+
return status === 'timed out' && Date.now() - lastUpdate <= EXPIRATION_DELAY;
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
...host,
|
|
167
|
+
status,
|
|
168
|
+
lastUpdate,
|
|
169
|
+
isUp,
|
|
170
|
+
isTimedOut
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function _defineProperty(obj, key, value) {
|
|
175
|
+
if (key in obj) {
|
|
176
|
+
Object.defineProperty(obj, key, {
|
|
177
|
+
value: value,
|
|
178
|
+
enumerable: true,
|
|
179
|
+
configurable: true,
|
|
180
|
+
writable: true
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
obj[key] = value;
|
|
184
|
+
}
|
|
185
|
+
return obj;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
class AlgoliaError extends Error {
|
|
189
|
+
constructor(message, name) {
|
|
190
|
+
super(message);
|
|
191
|
+
_defineProperty(this, "name", 'AlgoliaError');
|
|
192
|
+
if (name) {
|
|
193
|
+
this.name = name;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
class ErrorWithStackTrace extends AlgoliaError {
|
|
198
|
+
constructor(message, stackTrace, name) {
|
|
199
|
+
super(message, name);
|
|
200
|
+
// the array and object should be frozen to reflect the stackTrace at the time of the error
|
|
201
|
+
_defineProperty(this, "stackTrace", void 0);
|
|
202
|
+
this.stackTrace = stackTrace;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
class RetryError extends ErrorWithStackTrace {
|
|
206
|
+
constructor(stackTrace) {
|
|
207
|
+
super('Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.', stackTrace, 'RetryError');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
class ApiError extends ErrorWithStackTrace {
|
|
211
|
+
constructor(message, status, stackTrace) {
|
|
212
|
+
super(message, stackTrace, 'ApiError');
|
|
213
|
+
_defineProperty(this, "status", void 0);
|
|
214
|
+
this.status = status;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
class DeserializationError extends AlgoliaError {
|
|
218
|
+
constructor(message, response) {
|
|
219
|
+
super(message, 'DeserializationError');
|
|
220
|
+
_defineProperty(this, "response", void 0);
|
|
221
|
+
this.response = response;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function serializeUrl(host, path, queryParameters) {
|
|
225
|
+
const queryParametersAsString = serializeQueryParameters(queryParameters);
|
|
226
|
+
let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.substr(1) : path}`;
|
|
227
|
+
if (queryParametersAsString.length) {
|
|
228
|
+
url += `?${queryParametersAsString}`;
|
|
229
|
+
}
|
|
230
|
+
return url;
|
|
231
|
+
}
|
|
232
|
+
function serializeQueryParameters(parameters) {
|
|
233
|
+
const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
|
|
234
|
+
return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
|
|
235
|
+
}
|
|
236
|
+
function serializeData(request, requestOptions) {
|
|
237
|
+
if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
const data = Array.isArray(request.data) ? request.data : {
|
|
241
|
+
...request.data,
|
|
242
|
+
...requestOptions.data
|
|
243
|
+
};
|
|
244
|
+
return JSON.stringify(data);
|
|
245
|
+
}
|
|
246
|
+
function serializeHeaders(baseHeaders, requestHeaders, requestOptionsHeaders) {
|
|
247
|
+
const headers = {
|
|
248
|
+
Accept: 'application/json',
|
|
249
|
+
...baseHeaders,
|
|
250
|
+
...requestHeaders,
|
|
251
|
+
...requestOptionsHeaders
|
|
252
|
+
};
|
|
253
|
+
const serializedHeaders = {};
|
|
254
|
+
Object.keys(headers).forEach(header => {
|
|
255
|
+
const value = headers[header];
|
|
256
|
+
serializedHeaders[header.toLowerCase()] = value;
|
|
257
|
+
});
|
|
258
|
+
return serializedHeaders;
|
|
259
|
+
}
|
|
260
|
+
function deserializeSuccess(response) {
|
|
261
|
+
try {
|
|
262
|
+
return JSON.parse(response.content);
|
|
263
|
+
} catch (e) {
|
|
264
|
+
throw new DeserializationError(e.message, response);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function deserializeFailure({
|
|
268
|
+
content,
|
|
269
|
+
status
|
|
270
|
+
}, stackFrame) {
|
|
271
|
+
let message = content;
|
|
272
|
+
try {
|
|
273
|
+
message = JSON.parse(content).message;
|
|
274
|
+
} catch (e) {
|
|
275
|
+
// ..
|
|
276
|
+
}
|
|
277
|
+
return new ApiError(message, status, stackFrame);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function isNetworkError({
|
|
281
|
+
isTimedOut,
|
|
282
|
+
status
|
|
283
|
+
}) {
|
|
284
|
+
return !isTimedOut && ~~status === 0;
|
|
285
|
+
}
|
|
286
|
+
function isRetryable({
|
|
287
|
+
isTimedOut,
|
|
288
|
+
status
|
|
289
|
+
}) {
|
|
290
|
+
return isTimedOut || isNetworkError({
|
|
291
|
+
isTimedOut,
|
|
292
|
+
status
|
|
293
|
+
}) || ~~(status / 100) !== 2 && ~~(status / 100) !== 4;
|
|
294
|
+
}
|
|
295
|
+
function isSuccess({
|
|
296
|
+
status
|
|
297
|
+
}) {
|
|
298
|
+
return ~~(status / 100) === 2;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function stackTraceWithoutCredentials(stackTrace) {
|
|
302
|
+
return stackTrace.map(stackFrame => stackFrameWithoutCredentials(stackFrame));
|
|
303
|
+
}
|
|
304
|
+
function stackFrameWithoutCredentials(stackFrame) {
|
|
305
|
+
const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key'] ? {
|
|
306
|
+
'x-algolia-api-key': '*****'
|
|
307
|
+
} : {};
|
|
308
|
+
return {
|
|
309
|
+
...stackFrame,
|
|
310
|
+
request: {
|
|
311
|
+
...stackFrame.request,
|
|
312
|
+
headers: {
|
|
313
|
+
...stackFrame.request.headers,
|
|
314
|
+
...modifiedHeaders
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function createTransporter({
|
|
321
|
+
hosts,
|
|
322
|
+
hostsCache,
|
|
323
|
+
baseHeaders,
|
|
324
|
+
baseQueryParameters,
|
|
325
|
+
algoliaAgent,
|
|
326
|
+
timeouts,
|
|
327
|
+
requester,
|
|
328
|
+
requestsCache,
|
|
329
|
+
responsesCache
|
|
330
|
+
}) {
|
|
331
|
+
async function createRetryableOptions(compatibleHosts) {
|
|
332
|
+
const statefulHosts = await Promise.all(compatibleHosts.map(compatibleHost => {
|
|
333
|
+
return hostsCache.get(compatibleHost, () => {
|
|
334
|
+
return Promise.resolve(createStatefulHost(compatibleHost));
|
|
335
|
+
});
|
|
336
|
+
}));
|
|
337
|
+
const hostsUp = statefulHosts.filter(host => host.isUp());
|
|
338
|
+
const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut());
|
|
339
|
+
// Note, we put the hosts that previously timed out on the end of the list.
|
|
340
|
+
const hostsAvailable = [...hostsUp, ...hostsTimedOut];
|
|
341
|
+
const compatibleHostsAvailable = hostsAvailable.length > 0 ? hostsAvailable : compatibleHosts;
|
|
342
|
+
return {
|
|
343
|
+
hosts: compatibleHostsAvailable,
|
|
344
|
+
getTimeout(timeoutsCount, baseTimeout) {
|
|
345
|
+
/**
|
|
346
|
+
* Imagine that you have 4 hosts, if timeouts will increase
|
|
347
|
+
* on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
|
|
348
|
+
*
|
|
349
|
+
* Note that, the very next request, we start from the previous timeout.
|
|
350
|
+
*
|
|
351
|
+
* 5 (timed out) > 6 (timed out) > 7 ...
|
|
352
|
+
*
|
|
353
|
+
* This strategy may need to be reviewed, but is the strategy on the our
|
|
354
|
+
* current v3 version.
|
|
355
|
+
*/
|
|
356
|
+
const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
|
|
357
|
+
return timeoutMultiplier * baseTimeout;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
async function retryableRequest(request, requestOptions, isRead = true) {
|
|
362
|
+
const stackTrace = [];
|
|
363
|
+
/**
|
|
364
|
+
* First we prepare the payload that do not depend from hosts.
|
|
365
|
+
*/
|
|
366
|
+
const data = serializeData(request, requestOptions);
|
|
367
|
+
const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
|
|
368
|
+
// On `GET`, the data is proxied to query parameters.
|
|
369
|
+
const dataQueryParameters = request.method === 'GET' ? {
|
|
370
|
+
...request.data,
|
|
371
|
+
...requestOptions.data
|
|
372
|
+
} : {};
|
|
373
|
+
const queryParameters = {
|
|
374
|
+
...baseQueryParameters,
|
|
375
|
+
...request.queryParameters,
|
|
376
|
+
...dataQueryParameters
|
|
377
|
+
};
|
|
378
|
+
if (algoliaAgent.value) {
|
|
379
|
+
queryParameters['x-algolia-agent'] = algoliaAgent.value;
|
|
380
|
+
}
|
|
381
|
+
if (requestOptions && requestOptions.queryParameters) {
|
|
382
|
+
for (const key of Object.keys(requestOptions.queryParameters)) {
|
|
383
|
+
// We want to keep `undefined` and `null` values,
|
|
384
|
+
// but also avoid stringifying `object`s, as they are
|
|
385
|
+
// handled in the `serializeUrl` step right after.
|
|
386
|
+
if (!requestOptions.queryParameters[key] || Object.prototype.toString.call(requestOptions.queryParameters[key]) === '[object Object]') {
|
|
387
|
+
queryParameters[key] = requestOptions.queryParameters[key];
|
|
388
|
+
} else {
|
|
389
|
+
queryParameters[key] = requestOptions.queryParameters[key].toString();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
let timeoutsCount = 0;
|
|
394
|
+
const retry = async (retryableHosts, getTimeout) => {
|
|
395
|
+
/**
|
|
396
|
+
* We iterate on each host, until there is no host left.
|
|
397
|
+
*/
|
|
398
|
+
const host = retryableHosts.pop();
|
|
399
|
+
if (host === undefined) {
|
|
400
|
+
throw new RetryError(stackTraceWithoutCredentials(stackTrace));
|
|
401
|
+
}
|
|
402
|
+
let responseTimeout = requestOptions.timeout;
|
|
403
|
+
if (responseTimeout === undefined) {
|
|
404
|
+
responseTimeout = isRead ? timeouts.read : timeouts.write;
|
|
405
|
+
}
|
|
406
|
+
const payload = {
|
|
407
|
+
data,
|
|
408
|
+
headers,
|
|
409
|
+
method: request.method,
|
|
410
|
+
url: serializeUrl(host, request.path, queryParameters),
|
|
411
|
+
connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
|
|
412
|
+
responseTimeout: getTimeout(timeoutsCount, responseTimeout)
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
415
|
+
* The stackFrame is pushed to the stackTrace so we
|
|
416
|
+
* can have information about onRetry and onFailure
|
|
417
|
+
* decisions.
|
|
418
|
+
*/
|
|
419
|
+
const pushToStackTrace = response => {
|
|
420
|
+
const stackFrame = {
|
|
421
|
+
request: payload,
|
|
422
|
+
response,
|
|
423
|
+
host,
|
|
424
|
+
triesLeft: retryableHosts.length
|
|
425
|
+
};
|
|
426
|
+
stackTrace.push(stackFrame);
|
|
427
|
+
return stackFrame;
|
|
428
|
+
};
|
|
429
|
+
const response = await requester.send(payload);
|
|
430
|
+
if (isRetryable(response)) {
|
|
431
|
+
const stackFrame = pushToStackTrace(response);
|
|
432
|
+
// If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
|
|
433
|
+
if (response.isTimedOut) {
|
|
434
|
+
timeoutsCount++;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Failures are individually sent to the logger, allowing
|
|
438
|
+
* the end user to debug / store stack frames even
|
|
439
|
+
* when a retry error does not happen.
|
|
440
|
+
*/
|
|
441
|
+
// eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
|
|
442
|
+
console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
|
|
443
|
+
/**
|
|
444
|
+
* We also store the state of the host in failure cases. If the host, is
|
|
445
|
+
* down it will remain down for the next 2 minutes. In a timeout situation,
|
|
446
|
+
* this host will be added end of the list of hosts on the next request.
|
|
447
|
+
*/
|
|
448
|
+
await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
|
|
449
|
+
return retry(retryableHosts, getTimeout);
|
|
450
|
+
}
|
|
451
|
+
if (isSuccess(response)) {
|
|
452
|
+
return deserializeSuccess(response);
|
|
453
|
+
}
|
|
454
|
+
pushToStackTrace(response);
|
|
455
|
+
throw deserializeFailure(response, stackTrace);
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Finally, for each retryable host perform request until we got a non
|
|
459
|
+
* retryable response. Some notes here:
|
|
460
|
+
*
|
|
461
|
+
* 1. The reverse here is applied so we can apply a `pop` later on => more performant.
|
|
462
|
+
* 2. We also get from the retryable options a timeout multiplier that is tailored
|
|
463
|
+
* for the current context.
|
|
464
|
+
*/
|
|
465
|
+
const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
|
|
466
|
+
const options = await createRetryableOptions(compatibleHosts);
|
|
467
|
+
return retry([...options.hosts].reverse(), options.getTimeout);
|
|
468
|
+
}
|
|
469
|
+
function createRequest(request, requestOptions = {}) {
|
|
470
|
+
/**
|
|
471
|
+
* A read request is either a `GET` request, or a request that we make
|
|
472
|
+
* via the `read` transporter (e.g. `search`).
|
|
473
|
+
*/
|
|
474
|
+
const isRead = request.useReadTransporter || request.method === 'GET';
|
|
475
|
+
if (!isRead) {
|
|
476
|
+
/**
|
|
477
|
+
* On write requests, no cache mechanisms are applied, and we
|
|
478
|
+
* proxy the request immediately to the requester.
|
|
479
|
+
*/
|
|
480
|
+
return retryableRequest(request, requestOptions, isRead);
|
|
481
|
+
}
|
|
482
|
+
const createRetryableRequest = () => {
|
|
483
|
+
/**
|
|
484
|
+
* Then, we prepare a function factory that contains the construction of
|
|
485
|
+
* the retryable request. At this point, we may *not* perform the actual
|
|
486
|
+
* request. But we want to have the function factory ready.
|
|
487
|
+
*/
|
|
488
|
+
return retryableRequest(request, requestOptions);
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* Once we have the function factory ready, we need to determine of the
|
|
492
|
+
* request is "cacheable" - should be cached. Note that, once again,
|
|
493
|
+
* the user can force this option.
|
|
494
|
+
*/
|
|
495
|
+
const cacheable = requestOptions.cacheable || request.cacheable;
|
|
496
|
+
/**
|
|
497
|
+
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
498
|
+
* need to check cache implementations.
|
|
499
|
+
*/
|
|
500
|
+
if (cacheable !== true) {
|
|
501
|
+
return createRetryableRequest();
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* If the request is "cacheable", we need to first compute the key to ask
|
|
505
|
+
* the cache implementations if this request is on progress or if the
|
|
506
|
+
* response already exists on the cache.
|
|
507
|
+
*/
|
|
508
|
+
const key = {
|
|
509
|
+
request,
|
|
510
|
+
requestOptions,
|
|
511
|
+
transporter: {
|
|
512
|
+
queryParameters: baseQueryParameters,
|
|
513
|
+
headers: baseHeaders
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* With the computed key, we first ask the responses cache
|
|
518
|
+
* implementation if this request was been resolved before.
|
|
519
|
+
*/
|
|
520
|
+
return responsesCache.get(key, () => {
|
|
521
|
+
/**
|
|
522
|
+
* If the request has never resolved before, we actually ask if there
|
|
523
|
+
* is a current request with the same key on progress.
|
|
524
|
+
*/
|
|
525
|
+
return requestsCache.get(key, () =>
|
|
526
|
+
/**
|
|
527
|
+
* Finally, if there is no request in progress with the same key,
|
|
528
|
+
* this `createRetryableRequest()` will actually trigger the
|
|
529
|
+
* retryable request.
|
|
530
|
+
*/
|
|
531
|
+
requestsCache.set(key, createRetryableRequest()).then(response => Promise.all([requestsCache.delete(key), response]), err => Promise.all([requestsCache.delete(key), Promise.reject(err)])).then(([_, response]) => response));
|
|
532
|
+
}, {
|
|
533
|
+
/**
|
|
534
|
+
* Of course, once we get this response back from the server, we
|
|
535
|
+
* tell response cache to actually store the received response
|
|
536
|
+
* to be used later.
|
|
537
|
+
*/
|
|
538
|
+
miss: response => responsesCache.set(key, response)
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
hostsCache,
|
|
543
|
+
requester,
|
|
544
|
+
timeouts,
|
|
545
|
+
algoliaAgent,
|
|
546
|
+
baseHeaders,
|
|
547
|
+
baseQueryParameters,
|
|
548
|
+
hosts,
|
|
549
|
+
request: createRequest,
|
|
550
|
+
requestsCache,
|
|
551
|
+
responsesCache
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function createAlgoliaAgent(version) {
|
|
556
|
+
const algoliaAgent = {
|
|
557
|
+
value: `Algolia for JavaScript (${version})`,
|
|
558
|
+
add(options) {
|
|
559
|
+
const addedAlgoliaAgent = `; ${options.segment}${options.version !== undefined ? ` (${options.version})` : ''}`;
|
|
560
|
+
if (algoliaAgent.value.indexOf(addedAlgoliaAgent) === -1) {
|
|
561
|
+
algoliaAgent.value = `${algoliaAgent.value}${addedAlgoliaAgent}`;
|
|
562
|
+
}
|
|
563
|
+
return algoliaAgent;
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
return algoliaAgent;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function getAlgoliaAgent({
|
|
570
|
+
algoliaAgents,
|
|
571
|
+
client,
|
|
572
|
+
version
|
|
573
|
+
}) {
|
|
574
|
+
const defaultAlgoliaAgent = createAlgoliaAgent(version).add({
|
|
575
|
+
segment: client,
|
|
576
|
+
version
|
|
577
|
+
});
|
|
578
|
+
algoliaAgents.forEach(algoliaAgent => defaultAlgoliaAgent.add(algoliaAgent));
|
|
579
|
+
return defaultAlgoliaAgent;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
|
|
583
|
+
const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
|
|
584
|
+
const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
|
|
585
|
+
|
|
586
|
+
function createXhrRequester() {
|
|
587
|
+
function send(request) {
|
|
588
|
+
return new Promise((resolve) => {
|
|
589
|
+
const baseRequester = new XMLHttpRequest();
|
|
590
|
+
baseRequester.open(request.method, request.url, true);
|
|
591
|
+
Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
|
|
592
|
+
const createTimeout = (timeout, content) => {
|
|
593
|
+
return setTimeout(() => {
|
|
594
|
+
baseRequester.abort();
|
|
595
|
+
resolve({
|
|
596
|
+
status: 0,
|
|
597
|
+
content,
|
|
598
|
+
isTimedOut: true,
|
|
599
|
+
});
|
|
600
|
+
}, timeout);
|
|
601
|
+
};
|
|
602
|
+
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
|
|
603
|
+
let responseTimeout;
|
|
604
|
+
baseRequester.onreadystatechange = () => {
|
|
605
|
+
if (baseRequester.readyState > baseRequester.OPENED &&
|
|
606
|
+
responseTimeout === undefined) {
|
|
607
|
+
clearTimeout(connectTimeout);
|
|
608
|
+
responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
baseRequester.onerror = () => {
|
|
612
|
+
// istanbul ignore next
|
|
613
|
+
if (baseRequester.status === 0) {
|
|
614
|
+
clearTimeout(connectTimeout);
|
|
615
|
+
clearTimeout(responseTimeout);
|
|
616
|
+
resolve({
|
|
617
|
+
content: baseRequester.responseText || 'Network request failed',
|
|
618
|
+
status: baseRequester.status,
|
|
619
|
+
isTimedOut: false,
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
baseRequester.onload = () => {
|
|
624
|
+
clearTimeout(connectTimeout);
|
|
625
|
+
clearTimeout(responseTimeout);
|
|
626
|
+
resolve({
|
|
627
|
+
content: baseRequester.responseText,
|
|
628
|
+
status: baseRequester.status,
|
|
629
|
+
isTimedOut: false,
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
baseRequester.send(request.data);
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
return { send };
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
639
|
+
const apiClientVersion = '1.0.0-alpha.2';
|
|
640
|
+
const REGIONS = ['us'];
|
|
641
|
+
function getDefaultHosts(region) {
|
|
642
|
+
const url = 'data.{region}.algolia.com'.replace('{region}', region);
|
|
643
|
+
return [{ url, accept: 'readWrite', protocol: 'https' }];
|
|
644
|
+
}
|
|
645
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
646
|
+
function createIngestionClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
|
|
647
|
+
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
648
|
+
const transporter = createTransporter({
|
|
649
|
+
hosts: getDefaultHosts(regionOption),
|
|
650
|
+
...options,
|
|
651
|
+
algoliaAgent: {
|
|
652
|
+
...getAlgoliaAgent({
|
|
653
|
+
algoliaAgents,
|
|
654
|
+
client: 'Ingestion',
|
|
655
|
+
version: apiClientVersion,
|
|
656
|
+
}),
|
|
657
|
+
value: '',
|
|
658
|
+
},
|
|
659
|
+
baseHeaders: {
|
|
660
|
+
'content-type': 'text/plain',
|
|
661
|
+
...auth.headers(),
|
|
662
|
+
...options.baseHeaders,
|
|
663
|
+
},
|
|
664
|
+
baseQueryParameters: {
|
|
665
|
+
...auth.queryParameters(),
|
|
666
|
+
...options.baseQueryParameters,
|
|
667
|
+
},
|
|
668
|
+
});
|
|
669
|
+
return {
|
|
670
|
+
transporter,
|
|
671
|
+
/**
|
|
672
|
+
* The `appId` currently in use.
|
|
673
|
+
*/
|
|
674
|
+
appId: appIdOption,
|
|
675
|
+
/**
|
|
676
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
677
|
+
*/
|
|
678
|
+
clearCache() {
|
|
679
|
+
return Promise.all([
|
|
680
|
+
transporter.requestsCache.clear(),
|
|
681
|
+
transporter.responsesCache.clear(),
|
|
682
|
+
]).then(() => undefined);
|
|
683
|
+
},
|
|
684
|
+
/**
|
|
685
|
+
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
686
|
+
*/
|
|
687
|
+
get _ua() {
|
|
688
|
+
return transporter.algoliaAgent.value;
|
|
689
|
+
},
|
|
690
|
+
/**
|
|
691
|
+
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
692
|
+
*
|
|
693
|
+
* @param segment - The algolia agent (user-agent) segment to add.
|
|
694
|
+
* @param version - The version of the agent.
|
|
695
|
+
*/
|
|
696
|
+
addAlgoliaAgent(segment, version) {
|
|
697
|
+
transporter.algoliaAgent.add({ segment, version });
|
|
698
|
+
},
|
|
699
|
+
/**
|
|
700
|
+
* Create a authentication.
|
|
701
|
+
*
|
|
702
|
+
* @summary Create a authentication.
|
|
703
|
+
* @param authenticationCreate -.
|
|
704
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
705
|
+
*/
|
|
706
|
+
createAuthentication(authenticationCreate, requestOptions) {
|
|
707
|
+
if (!authenticationCreate) {
|
|
708
|
+
throw new Error('Parameter `authenticationCreate` is required when calling `createAuthentication`.');
|
|
709
|
+
}
|
|
710
|
+
const requestPath = '/1/authentications';
|
|
711
|
+
const headers = {};
|
|
712
|
+
const queryParameters = {};
|
|
713
|
+
const request = {
|
|
714
|
+
method: 'POST',
|
|
715
|
+
path: requestPath,
|
|
716
|
+
queryParameters,
|
|
717
|
+
headers,
|
|
718
|
+
data: authenticationCreate,
|
|
719
|
+
};
|
|
720
|
+
return transporter.request(request, requestOptions);
|
|
721
|
+
},
|
|
722
|
+
/**
|
|
723
|
+
* Create a destination.
|
|
724
|
+
*
|
|
725
|
+
* @summary Create a destination.
|
|
726
|
+
* @param destinationCreate -.
|
|
727
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
728
|
+
*/
|
|
729
|
+
createDestination(destinationCreate, requestOptions) {
|
|
730
|
+
if (!destinationCreate) {
|
|
731
|
+
throw new Error('Parameter `destinationCreate` is required when calling `createDestination`.');
|
|
732
|
+
}
|
|
733
|
+
const requestPath = '/1/destinations';
|
|
734
|
+
const headers = {};
|
|
735
|
+
const queryParameters = {};
|
|
736
|
+
const request = {
|
|
737
|
+
method: 'POST',
|
|
738
|
+
path: requestPath,
|
|
739
|
+
queryParameters,
|
|
740
|
+
headers,
|
|
741
|
+
data: destinationCreate,
|
|
742
|
+
};
|
|
743
|
+
return transporter.request(request, requestOptions);
|
|
744
|
+
},
|
|
745
|
+
/**
|
|
746
|
+
* Create a source.
|
|
747
|
+
*
|
|
748
|
+
* @summary Create a source.
|
|
749
|
+
* @param sourceCreate -.
|
|
750
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
751
|
+
*/
|
|
752
|
+
createSource(sourceCreate, requestOptions) {
|
|
753
|
+
if (!sourceCreate) {
|
|
754
|
+
throw new Error('Parameter `sourceCreate` is required when calling `createSource`.');
|
|
755
|
+
}
|
|
756
|
+
const requestPath = '/1/sources';
|
|
757
|
+
const headers = {};
|
|
758
|
+
const queryParameters = {};
|
|
759
|
+
const request = {
|
|
760
|
+
method: 'POST',
|
|
761
|
+
path: requestPath,
|
|
762
|
+
queryParameters,
|
|
763
|
+
headers,
|
|
764
|
+
data: sourceCreate,
|
|
765
|
+
};
|
|
766
|
+
return transporter.request(request, requestOptions);
|
|
767
|
+
},
|
|
768
|
+
/**
|
|
769
|
+
* Create a task.
|
|
770
|
+
*
|
|
771
|
+
* @summary Create a task.
|
|
772
|
+
* @param taskCreate -.
|
|
773
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
774
|
+
*/
|
|
775
|
+
createTask(taskCreate, requestOptions) {
|
|
776
|
+
if (!taskCreate) {
|
|
777
|
+
throw new Error('Parameter `taskCreate` is required when calling `createTask`.');
|
|
778
|
+
}
|
|
779
|
+
if (!taskCreate.sourceID) {
|
|
780
|
+
throw new Error('Parameter `taskCreate.sourceID` is required when calling `createTask`.');
|
|
781
|
+
}
|
|
782
|
+
if (!taskCreate.action) {
|
|
783
|
+
throw new Error('Parameter `taskCreate.action` is required when calling `createTask`.');
|
|
784
|
+
}
|
|
785
|
+
const requestPath = '/1/tasks';
|
|
786
|
+
const headers = {};
|
|
787
|
+
const queryParameters = {};
|
|
788
|
+
const request = {
|
|
789
|
+
method: 'POST',
|
|
790
|
+
path: requestPath,
|
|
791
|
+
queryParameters,
|
|
792
|
+
headers,
|
|
793
|
+
data: taskCreate,
|
|
794
|
+
};
|
|
795
|
+
return transporter.request(request, requestOptions);
|
|
796
|
+
},
|
|
797
|
+
/**
|
|
798
|
+
* Soft delete a authentication.
|
|
799
|
+
*
|
|
800
|
+
* @summary Delete a authentication.
|
|
801
|
+
* @param deleteAuthentication - The deleteAuthentication object.
|
|
802
|
+
* @param deleteAuthentication.authenticationID - The authentication uuid.
|
|
803
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
804
|
+
*/
|
|
805
|
+
deleteAuthentication({ authenticationID }, requestOptions) {
|
|
806
|
+
if (!authenticationID) {
|
|
807
|
+
throw new Error('Parameter `authenticationID` is required when calling `deleteAuthentication`.');
|
|
808
|
+
}
|
|
809
|
+
const requestPath = '/1/authentications/{authenticationID}'.replace('{authenticationID}', encodeURIComponent(authenticationID));
|
|
810
|
+
const headers = {};
|
|
811
|
+
const queryParameters = {};
|
|
812
|
+
const request = {
|
|
813
|
+
method: 'DELETE',
|
|
814
|
+
path: requestPath,
|
|
815
|
+
queryParameters,
|
|
816
|
+
headers,
|
|
817
|
+
};
|
|
818
|
+
return transporter.request(request, requestOptions);
|
|
819
|
+
},
|
|
820
|
+
/**
|
|
821
|
+
* Soft delete a destination.
|
|
822
|
+
*
|
|
823
|
+
* @summary Delete a destination.
|
|
824
|
+
* @param deleteDestination - The deleteDestination object.
|
|
825
|
+
* @param deleteDestination.destinationID - The destination uuid.
|
|
826
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
827
|
+
*/
|
|
828
|
+
deleteDestination({ destinationID }, requestOptions) {
|
|
829
|
+
if (!destinationID) {
|
|
830
|
+
throw new Error('Parameter `destinationID` is required when calling `deleteDestination`.');
|
|
831
|
+
}
|
|
832
|
+
const requestPath = '/1/destinations/{destinationID}'.replace('{destinationID}', encodeURIComponent(destinationID));
|
|
833
|
+
const headers = {};
|
|
834
|
+
const queryParameters = {};
|
|
835
|
+
const request = {
|
|
836
|
+
method: 'DELETE',
|
|
837
|
+
path: requestPath,
|
|
838
|
+
queryParameters,
|
|
839
|
+
headers,
|
|
840
|
+
};
|
|
841
|
+
return transporter.request(request, requestOptions);
|
|
842
|
+
},
|
|
843
|
+
/**
|
|
844
|
+
* Soft delete a source.
|
|
845
|
+
*
|
|
846
|
+
* @summary Delete a source.
|
|
847
|
+
* @param deleteSource - The deleteSource object.
|
|
848
|
+
* @param deleteSource.sourceID - The source uuid.
|
|
849
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
850
|
+
*/
|
|
851
|
+
deleteSource({ sourceID }, requestOptions) {
|
|
852
|
+
if (!sourceID) {
|
|
853
|
+
throw new Error('Parameter `sourceID` is required when calling `deleteSource`.');
|
|
854
|
+
}
|
|
855
|
+
const requestPath = '/1/sources/{sourceID}'.replace('{sourceID}', encodeURIComponent(sourceID));
|
|
856
|
+
const headers = {};
|
|
857
|
+
const queryParameters = {};
|
|
858
|
+
const request = {
|
|
859
|
+
method: 'DELETE',
|
|
860
|
+
path: requestPath,
|
|
861
|
+
queryParameters,
|
|
862
|
+
headers,
|
|
863
|
+
};
|
|
864
|
+
return transporter.request(request, requestOptions);
|
|
865
|
+
},
|
|
866
|
+
/**
|
|
867
|
+
* Soft delete a task.
|
|
868
|
+
*
|
|
869
|
+
* @summary Delete a task.
|
|
870
|
+
* @param deleteTask - The deleteTask object.
|
|
871
|
+
* @param deleteTask.taskID - The task uuid.
|
|
872
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
873
|
+
*/
|
|
874
|
+
deleteTask({ taskID }, requestOptions) {
|
|
875
|
+
if (!taskID) {
|
|
876
|
+
throw new Error('Parameter `taskID` is required when calling `deleteTask`.');
|
|
877
|
+
}
|
|
878
|
+
const requestPath = '/1/tasks/{taskID}'.replace('{taskID}', encodeURIComponent(taskID));
|
|
879
|
+
const headers = {};
|
|
880
|
+
const queryParameters = {};
|
|
881
|
+
const request = {
|
|
882
|
+
method: 'DELETE',
|
|
883
|
+
path: requestPath,
|
|
884
|
+
queryParameters,
|
|
885
|
+
headers,
|
|
886
|
+
};
|
|
887
|
+
return transporter.request(request, requestOptions);
|
|
888
|
+
},
|
|
889
|
+
/**
|
|
890
|
+
* Disable a task.
|
|
891
|
+
*
|
|
892
|
+
* @summary Disable a task.
|
|
893
|
+
* @param disableTask - The disableTask object.
|
|
894
|
+
* @param disableTask.taskID - The task uuid.
|
|
895
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
896
|
+
*/
|
|
897
|
+
disableTask({ taskID }, requestOptions) {
|
|
898
|
+
if (!taskID) {
|
|
899
|
+
throw new Error('Parameter `taskID` is required when calling `disableTask`.');
|
|
900
|
+
}
|
|
901
|
+
const requestPath = '/1/tasks/{taskID}/disable'.replace('{taskID}', encodeURIComponent(taskID));
|
|
902
|
+
const headers = {};
|
|
903
|
+
const queryParameters = {};
|
|
904
|
+
const request = {
|
|
905
|
+
method: 'POST',
|
|
906
|
+
path: requestPath,
|
|
907
|
+
queryParameters,
|
|
908
|
+
headers,
|
|
909
|
+
};
|
|
910
|
+
return transporter.request(request, requestOptions);
|
|
911
|
+
},
|
|
912
|
+
/**
|
|
913
|
+
* Enable a task.
|
|
914
|
+
*
|
|
915
|
+
* @summary Enable a task.
|
|
916
|
+
* @param enableTask - The enableTask object.
|
|
917
|
+
* @param enableTask.taskID - The task uuid.
|
|
918
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
919
|
+
*/
|
|
920
|
+
enableTask({ taskID }, requestOptions) {
|
|
921
|
+
if (!taskID) {
|
|
922
|
+
throw new Error('Parameter `taskID` is required when calling `enableTask`.');
|
|
923
|
+
}
|
|
924
|
+
const requestPath = '/1/tasks/{taskID}/enable'.replace('{taskID}', encodeURIComponent(taskID));
|
|
925
|
+
const headers = {};
|
|
926
|
+
const queryParameters = {};
|
|
927
|
+
const request = {
|
|
928
|
+
method: 'POST',
|
|
929
|
+
path: requestPath,
|
|
930
|
+
queryParameters,
|
|
931
|
+
headers,
|
|
932
|
+
};
|
|
933
|
+
return transporter.request(request, requestOptions);
|
|
934
|
+
},
|
|
935
|
+
/**
|
|
936
|
+
* Get a authentication.
|
|
937
|
+
*
|
|
938
|
+
* @summary Get a authentication.
|
|
939
|
+
* @param getAuthentication - The getAuthentication object.
|
|
940
|
+
* @param getAuthentication.authenticationID - The authentication uuid.
|
|
941
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
942
|
+
*/
|
|
943
|
+
getAuthentication({ authenticationID }, requestOptions) {
|
|
944
|
+
if (!authenticationID) {
|
|
945
|
+
throw new Error('Parameter `authenticationID` is required when calling `getAuthentication`.');
|
|
946
|
+
}
|
|
947
|
+
const requestPath = '/1/authentications/{authenticationID}'.replace('{authenticationID}', encodeURIComponent(authenticationID));
|
|
948
|
+
const headers = {};
|
|
949
|
+
const queryParameters = {};
|
|
950
|
+
const request = {
|
|
951
|
+
method: 'GET',
|
|
952
|
+
path: requestPath,
|
|
953
|
+
queryParameters,
|
|
954
|
+
headers,
|
|
955
|
+
};
|
|
956
|
+
return transporter.request(request, requestOptions);
|
|
957
|
+
},
|
|
958
|
+
/**
|
|
959
|
+
* Get a list of authentications.
|
|
960
|
+
*
|
|
961
|
+
* @summary Get a list of authentications.
|
|
962
|
+
* @param getAuthentications - The getAuthentications object.
|
|
963
|
+
* @param getAuthentications.itemsPerPage - The number of items per page to return.
|
|
964
|
+
* @param getAuthentications.page - The page number to fetch, starting at 1.
|
|
965
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
966
|
+
*/
|
|
967
|
+
getAuthentications({ itemsPerPage, page } = {}, requestOptions = undefined) {
|
|
968
|
+
const requestPath = '/1/authentications';
|
|
969
|
+
const headers = {};
|
|
970
|
+
const queryParameters = {};
|
|
971
|
+
if (itemsPerPage !== undefined) {
|
|
972
|
+
queryParameters.itemsPerPage = itemsPerPage.toString();
|
|
973
|
+
}
|
|
974
|
+
if (page !== undefined) {
|
|
975
|
+
queryParameters.page = page.toString();
|
|
976
|
+
}
|
|
977
|
+
const request = {
|
|
978
|
+
method: 'GET',
|
|
979
|
+
path: requestPath,
|
|
980
|
+
queryParameters,
|
|
981
|
+
headers,
|
|
982
|
+
};
|
|
983
|
+
return transporter.request(request, requestOptions);
|
|
984
|
+
},
|
|
985
|
+
/**
|
|
986
|
+
* Get a destination.
|
|
987
|
+
*
|
|
988
|
+
* @summary Get a destination.
|
|
989
|
+
* @param getDestination - The getDestination object.
|
|
990
|
+
* @param getDestination.destinationID - The destination uuid.
|
|
991
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
992
|
+
*/
|
|
993
|
+
getDestination({ destinationID }, requestOptions) {
|
|
994
|
+
if (!destinationID) {
|
|
995
|
+
throw new Error('Parameter `destinationID` is required when calling `getDestination`.');
|
|
996
|
+
}
|
|
997
|
+
const requestPath = '/1/destinations/{destinationID}'.replace('{destinationID}', encodeURIComponent(destinationID));
|
|
998
|
+
const headers = {};
|
|
999
|
+
const queryParameters = {};
|
|
1000
|
+
const request = {
|
|
1001
|
+
method: 'GET',
|
|
1002
|
+
path: requestPath,
|
|
1003
|
+
queryParameters,
|
|
1004
|
+
headers,
|
|
1005
|
+
};
|
|
1006
|
+
return transporter.request(request, requestOptions);
|
|
1007
|
+
},
|
|
1008
|
+
/**
|
|
1009
|
+
* Get a list of destinations.
|
|
1010
|
+
*
|
|
1011
|
+
* @summary Get a list of destinations.
|
|
1012
|
+
* @param getDestinations - The getDestinations object.
|
|
1013
|
+
* @param getDestinations.itemsPerPage - The number of items per page to return.
|
|
1014
|
+
* @param getDestinations.page - The page number to fetch, starting at 1.
|
|
1015
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1016
|
+
*/
|
|
1017
|
+
getDestinations({ itemsPerPage, page } = {}, requestOptions = undefined) {
|
|
1018
|
+
const requestPath = '/1/destinations';
|
|
1019
|
+
const headers = {};
|
|
1020
|
+
const queryParameters = {};
|
|
1021
|
+
if (itemsPerPage !== undefined) {
|
|
1022
|
+
queryParameters.itemsPerPage = itemsPerPage.toString();
|
|
1023
|
+
}
|
|
1024
|
+
if (page !== undefined) {
|
|
1025
|
+
queryParameters.page = page.toString();
|
|
1026
|
+
}
|
|
1027
|
+
const request = {
|
|
1028
|
+
method: 'GET',
|
|
1029
|
+
path: requestPath,
|
|
1030
|
+
queryParameters,
|
|
1031
|
+
headers,
|
|
1032
|
+
};
|
|
1033
|
+
return transporter.request(request, requestOptions);
|
|
1034
|
+
},
|
|
1035
|
+
/**
|
|
1036
|
+
* Get an event in a specific run.
|
|
1037
|
+
*
|
|
1038
|
+
* @summary Get an event in a specific run.
|
|
1039
|
+
* @param getEvent - The getEvent object.
|
|
1040
|
+
* @param getEvent.runID - The run uuid.
|
|
1041
|
+
* @param getEvent.eventID - The event uuid.
|
|
1042
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1043
|
+
*/
|
|
1044
|
+
getEvent({ runID, eventID }, requestOptions) {
|
|
1045
|
+
if (!runID) {
|
|
1046
|
+
throw new Error('Parameter `runID` is required when calling `getEvent`.');
|
|
1047
|
+
}
|
|
1048
|
+
if (!eventID) {
|
|
1049
|
+
throw new Error('Parameter `eventID` is required when calling `getEvent`.');
|
|
1050
|
+
}
|
|
1051
|
+
const requestPath = '/1/runs/{runID}/events/{eventID}'
|
|
1052
|
+
.replace('{runID}', encodeURIComponent(runID))
|
|
1053
|
+
.replace('{eventID}', encodeURIComponent(eventID));
|
|
1054
|
+
const headers = {};
|
|
1055
|
+
const queryParameters = {};
|
|
1056
|
+
const request = {
|
|
1057
|
+
method: 'GET',
|
|
1058
|
+
path: requestPath,
|
|
1059
|
+
queryParameters,
|
|
1060
|
+
headers,
|
|
1061
|
+
};
|
|
1062
|
+
return transporter.request(request, requestOptions);
|
|
1063
|
+
},
|
|
1064
|
+
/**
|
|
1065
|
+
* Get a list of events for a specific run.
|
|
1066
|
+
*
|
|
1067
|
+
* @summary Get a list of events for a specific run.
|
|
1068
|
+
* @param getEvents - The getEvents object.
|
|
1069
|
+
* @param getEvents.runID - The run uuid.
|
|
1070
|
+
* @param getEvents.itemsPerPage - The number of items per page to return.
|
|
1071
|
+
* @param getEvents.page - The page number to fetch, starting at 1.
|
|
1072
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1073
|
+
*/
|
|
1074
|
+
getEvents({ runID, itemsPerPage, page }, requestOptions) {
|
|
1075
|
+
if (!runID) {
|
|
1076
|
+
throw new Error('Parameter `runID` is required when calling `getEvents`.');
|
|
1077
|
+
}
|
|
1078
|
+
const requestPath = '/1/runs/{runID}/events'.replace('{runID}', encodeURIComponent(runID));
|
|
1079
|
+
const headers = {};
|
|
1080
|
+
const queryParameters = {};
|
|
1081
|
+
if (itemsPerPage !== undefined) {
|
|
1082
|
+
queryParameters.itemsPerPage = itemsPerPage.toString();
|
|
1083
|
+
}
|
|
1084
|
+
if (page !== undefined) {
|
|
1085
|
+
queryParameters.page = page.toString();
|
|
1086
|
+
}
|
|
1087
|
+
const request = {
|
|
1088
|
+
method: 'GET',
|
|
1089
|
+
path: requestPath,
|
|
1090
|
+
queryParameters,
|
|
1091
|
+
headers,
|
|
1092
|
+
};
|
|
1093
|
+
return transporter.request(request, requestOptions);
|
|
1094
|
+
},
|
|
1095
|
+
/**
|
|
1096
|
+
* Get a run.
|
|
1097
|
+
*
|
|
1098
|
+
* @summary Get a run.
|
|
1099
|
+
* @param getRun - The getRun object.
|
|
1100
|
+
* @param getRun.runID - The run uuid.
|
|
1101
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1102
|
+
*/
|
|
1103
|
+
getRun({ runID }, requestOptions) {
|
|
1104
|
+
if (!runID) {
|
|
1105
|
+
throw new Error('Parameter `runID` is required when calling `getRun`.');
|
|
1106
|
+
}
|
|
1107
|
+
const requestPath = '/1/runs/{runID}'.replace('{runID}', encodeURIComponent(runID));
|
|
1108
|
+
const headers = {};
|
|
1109
|
+
const queryParameters = {};
|
|
1110
|
+
const request = {
|
|
1111
|
+
method: 'GET',
|
|
1112
|
+
path: requestPath,
|
|
1113
|
+
queryParameters,
|
|
1114
|
+
headers,
|
|
1115
|
+
};
|
|
1116
|
+
return transporter.request(request, requestOptions);
|
|
1117
|
+
},
|
|
1118
|
+
/**
|
|
1119
|
+
* Get a list of runs.
|
|
1120
|
+
*
|
|
1121
|
+
* @summary Get a list of runs.
|
|
1122
|
+
* @param getRuns - The getRuns object.
|
|
1123
|
+
* @param getRuns.itemsPerPage - The number of items per page to return.
|
|
1124
|
+
* @param getRuns.page - The page number to fetch, starting at 1.
|
|
1125
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1126
|
+
*/
|
|
1127
|
+
getRuns({ itemsPerPage, page } = {}, requestOptions = undefined) {
|
|
1128
|
+
const requestPath = '/1/runs';
|
|
1129
|
+
const headers = {};
|
|
1130
|
+
const queryParameters = {};
|
|
1131
|
+
if (itemsPerPage !== undefined) {
|
|
1132
|
+
queryParameters.itemsPerPage = itemsPerPage.toString();
|
|
1133
|
+
}
|
|
1134
|
+
if (page !== undefined) {
|
|
1135
|
+
queryParameters.page = page.toString();
|
|
1136
|
+
}
|
|
1137
|
+
const request = {
|
|
1138
|
+
method: 'GET',
|
|
1139
|
+
path: requestPath,
|
|
1140
|
+
queryParameters,
|
|
1141
|
+
headers,
|
|
1142
|
+
};
|
|
1143
|
+
return transporter.request(request, requestOptions);
|
|
1144
|
+
},
|
|
1145
|
+
/**
|
|
1146
|
+
* Get a list of runs associated with a taskID.
|
|
1147
|
+
*
|
|
1148
|
+
* @summary Get a list of runs associated with a taskID.
|
|
1149
|
+
* @param getRunsByTaskID - The getRunsByTaskID object.
|
|
1150
|
+
* @param getRunsByTaskID.taskID - The task uuid.
|
|
1151
|
+
* @param getRunsByTaskID.itemsPerPage - The number of items per page to return.
|
|
1152
|
+
* @param getRunsByTaskID.page - The page number to fetch, starting at 1.
|
|
1153
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1154
|
+
*/
|
|
1155
|
+
getRunsByTaskID({ taskID, itemsPerPage, page }, requestOptions) {
|
|
1156
|
+
if (!taskID) {
|
|
1157
|
+
throw new Error('Parameter `taskID` is required when calling `getRunsByTaskID`.');
|
|
1158
|
+
}
|
|
1159
|
+
const requestPath = '/1/runs/tasks/{taskID}'.replace('{taskID}', encodeURIComponent(taskID));
|
|
1160
|
+
const headers = {};
|
|
1161
|
+
const queryParameters = {};
|
|
1162
|
+
if (itemsPerPage !== undefined) {
|
|
1163
|
+
queryParameters.itemsPerPage = itemsPerPage.toString();
|
|
1164
|
+
}
|
|
1165
|
+
if (page !== undefined) {
|
|
1166
|
+
queryParameters.page = page.toString();
|
|
1167
|
+
}
|
|
1168
|
+
const request = {
|
|
1169
|
+
method: 'GET',
|
|
1170
|
+
path: requestPath,
|
|
1171
|
+
queryParameters,
|
|
1172
|
+
headers,
|
|
1173
|
+
};
|
|
1174
|
+
return transporter.request(request, requestOptions);
|
|
1175
|
+
},
|
|
1176
|
+
/**
|
|
1177
|
+
* Get a source.
|
|
1178
|
+
*
|
|
1179
|
+
* @summary Get a source.
|
|
1180
|
+
* @param getSource - The getSource object.
|
|
1181
|
+
* @param getSource.sourceID - The source uuid.
|
|
1182
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1183
|
+
*/
|
|
1184
|
+
getSource({ sourceID }, requestOptions) {
|
|
1185
|
+
if (!sourceID) {
|
|
1186
|
+
throw new Error('Parameter `sourceID` is required when calling `getSource`.');
|
|
1187
|
+
}
|
|
1188
|
+
const requestPath = '/1/sources/{sourceID}'.replace('{sourceID}', encodeURIComponent(sourceID));
|
|
1189
|
+
const headers = {};
|
|
1190
|
+
const queryParameters = {};
|
|
1191
|
+
const request = {
|
|
1192
|
+
method: 'GET',
|
|
1193
|
+
path: requestPath,
|
|
1194
|
+
queryParameters,
|
|
1195
|
+
headers,
|
|
1196
|
+
};
|
|
1197
|
+
return transporter.request(request, requestOptions);
|
|
1198
|
+
},
|
|
1199
|
+
/**
|
|
1200
|
+
* Get a list of sources.
|
|
1201
|
+
*
|
|
1202
|
+
* @summary Get a list of sources.
|
|
1203
|
+
* @param getSources - The getSources object.
|
|
1204
|
+
* @param getSources.itemsPerPage - The number of items per page to return.
|
|
1205
|
+
* @param getSources.page - The page number to fetch, starting at 1.
|
|
1206
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1207
|
+
*/
|
|
1208
|
+
getSources({ itemsPerPage, page } = {}, requestOptions = undefined) {
|
|
1209
|
+
const requestPath = '/1/sources';
|
|
1210
|
+
const headers = {};
|
|
1211
|
+
const queryParameters = {};
|
|
1212
|
+
if (itemsPerPage !== undefined) {
|
|
1213
|
+
queryParameters.itemsPerPage = itemsPerPage.toString();
|
|
1214
|
+
}
|
|
1215
|
+
if (page !== undefined) {
|
|
1216
|
+
queryParameters.page = page.toString();
|
|
1217
|
+
}
|
|
1218
|
+
const request = {
|
|
1219
|
+
method: 'GET',
|
|
1220
|
+
path: requestPath,
|
|
1221
|
+
queryParameters,
|
|
1222
|
+
headers,
|
|
1223
|
+
};
|
|
1224
|
+
return transporter.request(request, requestOptions);
|
|
1225
|
+
},
|
|
1226
|
+
/**
|
|
1227
|
+
* Get a task.
|
|
1228
|
+
*
|
|
1229
|
+
* @summary Get a task.
|
|
1230
|
+
* @param getTask - The getTask object.
|
|
1231
|
+
* @param getTask.taskID - The task uuid.
|
|
1232
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1233
|
+
*/
|
|
1234
|
+
getTask({ taskID }, requestOptions) {
|
|
1235
|
+
if (!taskID) {
|
|
1236
|
+
throw new Error('Parameter `taskID` is required when calling `getTask`.');
|
|
1237
|
+
}
|
|
1238
|
+
const requestPath = '/1/tasks/{taskID}'.replace('{taskID}', encodeURIComponent(taskID));
|
|
1239
|
+
const headers = {};
|
|
1240
|
+
const queryParameters = {};
|
|
1241
|
+
const request = {
|
|
1242
|
+
method: 'GET',
|
|
1243
|
+
path: requestPath,
|
|
1244
|
+
queryParameters,
|
|
1245
|
+
headers,
|
|
1246
|
+
};
|
|
1247
|
+
return transporter.request(request, requestOptions);
|
|
1248
|
+
},
|
|
1249
|
+
/**
|
|
1250
|
+
* Get a list of tasks.
|
|
1251
|
+
*
|
|
1252
|
+
* @summary Get a list of tasks.
|
|
1253
|
+
* @param getTasks - The getTasks object.
|
|
1254
|
+
* @param getTasks.itemsPerPage - The number of items per page to return.
|
|
1255
|
+
* @param getTasks.page - The page number to fetch, starting at 1.
|
|
1256
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1257
|
+
*/
|
|
1258
|
+
getTasks({ itemsPerPage, page } = {}, requestOptions = undefined) {
|
|
1259
|
+
const requestPath = '/1/tasks';
|
|
1260
|
+
const headers = {};
|
|
1261
|
+
const queryParameters = {};
|
|
1262
|
+
if (itemsPerPage !== undefined) {
|
|
1263
|
+
queryParameters.itemsPerPage = itemsPerPage.toString();
|
|
1264
|
+
}
|
|
1265
|
+
if (page !== undefined) {
|
|
1266
|
+
queryParameters.page = page.toString();
|
|
1267
|
+
}
|
|
1268
|
+
const request = {
|
|
1269
|
+
method: 'GET',
|
|
1270
|
+
path: requestPath,
|
|
1271
|
+
queryParameters,
|
|
1272
|
+
headers,
|
|
1273
|
+
};
|
|
1274
|
+
return transporter.request(request, requestOptions);
|
|
1275
|
+
},
|
|
1276
|
+
/**
|
|
1277
|
+
* Run a task.
|
|
1278
|
+
*
|
|
1279
|
+
* @summary Run a task.
|
|
1280
|
+
* @param runTask - The runTask object.
|
|
1281
|
+
* @param runTask.taskID - The task uuid.
|
|
1282
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1283
|
+
*/
|
|
1284
|
+
runTask({ taskID }, requestOptions) {
|
|
1285
|
+
if (!taskID) {
|
|
1286
|
+
throw new Error('Parameter `taskID` is required when calling `runTask`.');
|
|
1287
|
+
}
|
|
1288
|
+
const requestPath = '/1/tasks/{taskID}/run'.replace('{taskID}', encodeURIComponent(taskID));
|
|
1289
|
+
const headers = {};
|
|
1290
|
+
const queryParameters = {};
|
|
1291
|
+
const request = {
|
|
1292
|
+
method: 'POST',
|
|
1293
|
+
path: requestPath,
|
|
1294
|
+
queryParameters,
|
|
1295
|
+
headers,
|
|
1296
|
+
};
|
|
1297
|
+
return transporter.request(request, requestOptions);
|
|
1298
|
+
},
|
|
1299
|
+
/**
|
|
1300
|
+
* Update a authentication.
|
|
1301
|
+
*
|
|
1302
|
+
* @summary Update a authentication.
|
|
1303
|
+
* @param updateAuthentication - The updateAuthentication object.
|
|
1304
|
+
* @param updateAuthentication.authenticationID - The authentication uuid.
|
|
1305
|
+
* @param updateAuthentication.authenticationUpdate - The authenticationUpdate object.
|
|
1306
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1307
|
+
*/
|
|
1308
|
+
updateAuthentication({ authenticationID, authenticationUpdate }, requestOptions) {
|
|
1309
|
+
if (!authenticationID) {
|
|
1310
|
+
throw new Error('Parameter `authenticationID` is required when calling `updateAuthentication`.');
|
|
1311
|
+
}
|
|
1312
|
+
if (!authenticationUpdate) {
|
|
1313
|
+
throw new Error('Parameter `authenticationUpdate` is required when calling `updateAuthentication`.');
|
|
1314
|
+
}
|
|
1315
|
+
const requestPath = '/1/authentications/{authenticationID}'.replace('{authenticationID}', encodeURIComponent(authenticationID));
|
|
1316
|
+
const headers = {};
|
|
1317
|
+
const queryParameters = {};
|
|
1318
|
+
const request = {
|
|
1319
|
+
method: 'PUT',
|
|
1320
|
+
path: requestPath,
|
|
1321
|
+
queryParameters,
|
|
1322
|
+
headers,
|
|
1323
|
+
data: authenticationUpdate,
|
|
1324
|
+
};
|
|
1325
|
+
return transporter.request(request, requestOptions);
|
|
1326
|
+
},
|
|
1327
|
+
/**
|
|
1328
|
+
* Update a destination.
|
|
1329
|
+
*
|
|
1330
|
+
* @summary Update a destination.
|
|
1331
|
+
* @param updateDestination - The updateDestination object.
|
|
1332
|
+
* @param updateDestination.destinationID - The destination uuid.
|
|
1333
|
+
* @param updateDestination.destinationUpdate - The destinationUpdate object.
|
|
1334
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1335
|
+
*/
|
|
1336
|
+
updateDestination({ destinationID, destinationUpdate }, requestOptions) {
|
|
1337
|
+
if (!destinationID) {
|
|
1338
|
+
throw new Error('Parameter `destinationID` is required when calling `updateDestination`.');
|
|
1339
|
+
}
|
|
1340
|
+
if (!destinationUpdate) {
|
|
1341
|
+
throw new Error('Parameter `destinationUpdate` is required when calling `updateDestination`.');
|
|
1342
|
+
}
|
|
1343
|
+
const requestPath = '/1/destinations/{destinationID}'.replace('{destinationID}', encodeURIComponent(destinationID));
|
|
1344
|
+
const headers = {};
|
|
1345
|
+
const queryParameters = {};
|
|
1346
|
+
const request = {
|
|
1347
|
+
method: 'PUT',
|
|
1348
|
+
path: requestPath,
|
|
1349
|
+
queryParameters,
|
|
1350
|
+
headers,
|
|
1351
|
+
data: destinationUpdate,
|
|
1352
|
+
};
|
|
1353
|
+
return transporter.request(request, requestOptions);
|
|
1354
|
+
},
|
|
1355
|
+
/**
|
|
1356
|
+
* Update a source.
|
|
1357
|
+
*
|
|
1358
|
+
* @summary Update a source.
|
|
1359
|
+
* @param updateSource - The updateSource object.
|
|
1360
|
+
* @param updateSource.sourceID - The source uuid.
|
|
1361
|
+
* @param updateSource.sourceUpdate - The sourceUpdate object.
|
|
1362
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1363
|
+
*/
|
|
1364
|
+
updateSource({ sourceID, sourceUpdate }, requestOptions) {
|
|
1365
|
+
if (!sourceID) {
|
|
1366
|
+
throw new Error('Parameter `sourceID` is required when calling `updateSource`.');
|
|
1367
|
+
}
|
|
1368
|
+
if (!sourceUpdate) {
|
|
1369
|
+
throw new Error('Parameter `sourceUpdate` is required when calling `updateSource`.');
|
|
1370
|
+
}
|
|
1371
|
+
const requestPath = '/1/sources/{sourceID}'.replace('{sourceID}', encodeURIComponent(sourceID));
|
|
1372
|
+
const headers = {};
|
|
1373
|
+
const queryParameters = {};
|
|
1374
|
+
const request = {
|
|
1375
|
+
method: 'POST',
|
|
1376
|
+
path: requestPath,
|
|
1377
|
+
queryParameters,
|
|
1378
|
+
headers,
|
|
1379
|
+
data: sourceUpdate,
|
|
1380
|
+
};
|
|
1381
|
+
return transporter.request(request, requestOptions);
|
|
1382
|
+
},
|
|
1383
|
+
/**
|
|
1384
|
+
* Update a task.
|
|
1385
|
+
*
|
|
1386
|
+
* @summary Update a task.
|
|
1387
|
+
* @param updateTask - The updateTask object.
|
|
1388
|
+
* @param updateTask.taskID - The task uuid.
|
|
1389
|
+
* @param updateTask.taskUpdate - The taskUpdate object.
|
|
1390
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1391
|
+
*/
|
|
1392
|
+
updateTask({ taskID, taskUpdate }, requestOptions) {
|
|
1393
|
+
if (!taskID) {
|
|
1394
|
+
throw new Error('Parameter `taskID` is required when calling `updateTask`.');
|
|
1395
|
+
}
|
|
1396
|
+
if (!taskUpdate) {
|
|
1397
|
+
throw new Error('Parameter `taskUpdate` is required when calling `updateTask`.');
|
|
1398
|
+
}
|
|
1399
|
+
const requestPath = '/1/tasks/{taskID}'.replace('{taskID}', encodeURIComponent(taskID));
|
|
1400
|
+
const headers = {};
|
|
1401
|
+
const queryParameters = {};
|
|
1402
|
+
const request = {
|
|
1403
|
+
method: 'PUT',
|
|
1404
|
+
path: requestPath,
|
|
1405
|
+
queryParameters,
|
|
1406
|
+
headers,
|
|
1407
|
+
data: taskUpdate,
|
|
1408
|
+
};
|
|
1409
|
+
return transporter.request(request, requestOptions);
|
|
1410
|
+
},
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
1415
|
+
function ingestionClient(appId, apiKey, region, options) {
|
|
1416
|
+
if (!appId || typeof appId !== 'string') {
|
|
1417
|
+
throw new Error('`appId` is missing.');
|
|
1418
|
+
}
|
|
1419
|
+
if (!apiKey || typeof apiKey !== 'string') {
|
|
1420
|
+
throw new Error('`apiKey` is missing.');
|
|
1421
|
+
}
|
|
1422
|
+
if (!region ||
|
|
1423
|
+
(region && (typeof region !== 'string' || !REGIONS.includes(region)))) {
|
|
1424
|
+
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(', ')}`);
|
|
1425
|
+
}
|
|
1426
|
+
return createIngestionClient({
|
|
1427
|
+
appId,
|
|
1428
|
+
apiKey,
|
|
1429
|
+
region,
|
|
1430
|
+
timeouts: {
|
|
1431
|
+
connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
|
|
1432
|
+
read: DEFAULT_READ_TIMEOUT_BROWSER,
|
|
1433
|
+
write: DEFAULT_WRITE_TIMEOUT_BROWSER,
|
|
1434
|
+
},
|
|
1435
|
+
requester: createXhrRequester(),
|
|
1436
|
+
algoliaAgents: [{ segment: 'Browser' }],
|
|
1437
|
+
authMode: 'WithinQueryParameters',
|
|
1438
|
+
responsesCache: createMemoryCache(),
|
|
1439
|
+
requestsCache: createMemoryCache({ serializable: false }),
|
|
1440
|
+
hostsCache: createFallbackableCache({
|
|
1441
|
+
caches: [
|
|
1442
|
+
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
|
|
1443
|
+
createMemoryCache(),
|
|
1444
|
+
],
|
|
1445
|
+
}),
|
|
1446
|
+
...options,
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
export { apiClientVersion, ingestionClient };
|