@getjones/test-infra 1.0.13 → 1.0.14
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/package.json
CHANGED
|
@@ -2,14 +2,19 @@ const requests = require('../../common/requests');
|
|
|
2
2
|
const { backendUrl } = require('../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
|
-
|
|
5
|
+
createApiKey: `${backendUrl}/saas/api-keys`,
|
|
6
|
+
initializeApiKeyOnAws: `${backendUrl}/saas/api-keys/aws`,
|
|
6
7
|
getApiKeyByAccountId: accountId => `${backendUrl}/saas/accounts/${accountId}/api-keys`,
|
|
7
8
|
getApiKeyDetails: `${backendUrl}/saas/api-keys`,
|
|
8
9
|
removeApiKey: `${backendUrl}/saas/api-keys`
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
-
return requests.postRequestHandler(Endpoints.
|
|
12
|
+
const createApiKey = async (data, context) => {
|
|
13
|
+
return requests.postRequestHandler(Endpoints.createApiKey, data, context).then(res => res.data);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const initializeApiKeyOnAws = async (data, context) => {
|
|
17
|
+
return requests.postRequestHandler(Endpoints.initializeApiKeyOnAws, data, context).then(res => res.data);
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
const getApiKeyByAccountId = async (accountId, context) => {
|
|
@@ -24,4 +29,4 @@ const deleteApiKey = async (data, context) => {
|
|
|
24
29
|
return requests.deleteRequestHandler(Endpoints.removeApiKey, context, {}, {}, data);
|
|
25
30
|
};
|
|
26
31
|
|
|
27
|
-
module.exports = {
|
|
32
|
+
module.exports = { createApiKey, getApiKeyByAccountId, getApiKeyDetails, deleteApiKey, initializeApiKeyOnAws };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
const accountsAPI = require('./accounts.openapi.api');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const createApiKey = async (accountId, apiKeyValue, context) => {
|
|
4
4
|
const data = { apiKeyValue, accountId };
|
|
5
|
-
return accountsAPI.
|
|
5
|
+
return accountsAPI.createApiKey(data, context);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const initializeApiKeyOnAws = async (accountId, apiKeyValue, context) => {
|
|
9
|
+
const data = { apiKeyValue, accountId };
|
|
10
|
+
return accountsAPI.initializeApiKeyOnAws(data, context);
|
|
6
11
|
};
|
|
7
12
|
|
|
8
13
|
const getApiKeyByAccountId = async (accountId, context) => {
|
|
@@ -18,20 +23,21 @@ const deleteApiKey = async (apiKeyValue, context) => {
|
|
|
18
23
|
return accountsAPI.deleteApiKey(data, context);
|
|
19
24
|
};
|
|
20
25
|
|
|
21
|
-
const
|
|
26
|
+
const getOrCreateApiKey = async (accountId, apiKey, context) => {
|
|
22
27
|
const existingApiKey = await getApiKeyByAccountId(accountId, context);
|
|
23
28
|
|
|
24
|
-
if (!existingApiKey.
|
|
25
|
-
return
|
|
29
|
+
if (!existingApiKey.apiKeyValue) {
|
|
30
|
+
return createApiKey(accountId, apiKey, context);
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
return existingApiKey;
|
|
29
34
|
};
|
|
30
35
|
|
|
31
36
|
module.exports = {
|
|
32
|
-
|
|
37
|
+
createApiKey,
|
|
33
38
|
getApiKeyByAccountId,
|
|
34
39
|
getApiKeyDetails,
|
|
35
40
|
deleteApiKey,
|
|
36
|
-
|
|
41
|
+
getOrCreateApiKey,
|
|
42
|
+
initializeApiKeyOnAws
|
|
37
43
|
};
|