@axway/axway-central-cli 2.5.1 → 2.6.1

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.
@@ -1,114 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ApiCentralClient = void 0;
7
-
8
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
-
10
- var _dataService = require("./dataService");
11
-
12
- var _types = require("./types");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
-
18
- const {
19
- log
20
- } = (0, _snooplogg.default)('central:class.ApiCentralClient');
21
-
22
- class ApiCentralClient {
23
- constructor({
24
- baseUrl,
25
- region,
26
- account
27
- }) {
28
- _defineProperty(this, "baseUrl", void 0);
29
-
30
- _defineProperty(this, "region", void 0);
31
-
32
- _defineProperty(this, "account", void 0);
33
-
34
- log(`initializing client with params: baseUrl = ${baseUrl}, region = ${region}, account = ${account}`);
35
- this.baseUrl = baseUrl;
36
- this.account = account;
37
- this.region = region;
38
- }
39
- /**
40
- * Create DOSA account.
41
- * @param accountName name of dosa account (can be non-unique)
42
- * @param publicKey public .pem file content
43
- */
44
-
45
-
46
- async createDOSAAccount(accountName, publicKey) {
47
- log(`createDOSAAccount`);
48
- const result = {
49
- data: null,
50
- error: null
51
- };
52
-
53
- try {
54
- const service = await (0, _dataService.dataService)({
55
- baseUrl: this.baseUrl,
56
- basePath: _types.BasePaths.ApiCentral,
57
- account: this.account,
58
- region: this.region
59
- });
60
- const payload = {
61
- generateKeypair: false,
62
- pemEncodedPublicKey: publicKey.replace(/(\r\n)/gm, '\n'),
63
- serviceAccountName: accountName,
64
- serviceAccountType: 'DOSA'
65
- };
66
- const response = await service.post('/serviceAccounts', payload);
67
- result.data = response;
68
- } catch (e) {
69
- log('createDOSAAccount, error: ', e); // expecting only a valid ApiServer error response here
70
- // re-throw if something different, so it should be handled by command's catch block.
71
-
72
- if (e.errors && Array.isArray(e.errors)) {
73
- result.error = e.errors;
74
- } else throw e;
75
- }
76
-
77
- return result;
78
- }
79
- /**
80
- * List service accounts.
81
- */
82
-
83
-
84
- async getServiceAccounts() {
85
- log(`getServiceAccounts`);
86
- const result = {
87
- data: null,
88
- error: null
89
- };
90
-
91
- try {
92
- const service = await (0, _dataService.dataService)({
93
- baseUrl: this.baseUrl,
94
- basePath: _types.BasePaths.ApiCentral,
95
- account: this.account,
96
- region: this.region
97
- });
98
- const response = await service.getWithPagination(`/serviceAccounts`, 'type==SA&sort=modifyTime%2CDESC');
99
- result.data = response;
100
- } catch (e) {
101
- log('getServiceAccounts, error: ', e); // expecting only a valid ApiServer error response here
102
- // re-throw if something different, so it should be handled by command's catch block.
103
-
104
- if (e.errors && Array.isArray(e.errors)) {
105
- result.error = e.errors;
106
- } else throw e;
107
- }
108
-
109
- return result;
110
- }
111
-
112
- }
113
-
114
- exports.ApiCentralClient = ApiCentralClient;