files.com 1.0.214 → 1.0.216

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/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.214
1
+ 1.0.216
@@ -0,0 +1,109 @@
1
+ # SftpHostKey
2
+
3
+ ## Example SftpHostKey Object
4
+
5
+ ```
6
+ {
7
+ "id": 1,
8
+ "name": "",
9
+ "fingerprint_md5": "",
10
+ "fingerprint_sha256": ""
11
+ }
12
+ ```
13
+
14
+ * `id` (int64): Sftp Host Key ID
15
+ * `name` (string): The friendly name of this SFTP Host Key.
16
+ * `fingerprint_md5` (string): MD5 Fingerpint of the public key
17
+ * `fingerprint_sha256` (string): SHA256 Fingerpint of the public key
18
+ * `private_key` (string): The private key data.
19
+
20
+ ---
21
+
22
+ ## List Sftp Host Keys
23
+
24
+ ```
25
+ await SftpHostKey.list({
26
+ 'per_page': 1,
27
+ })
28
+ ```
29
+
30
+
31
+ ### Parameters
32
+
33
+ * `cursor` (string): Used for pagination. Send a cursor value to resume an existing list from the point at which you left off. Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
34
+ * `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
35
+
36
+ ---
37
+
38
+ ## Show Sftp Host Key
39
+
40
+ ```
41
+ await SftpHostKey.find(id)
42
+ ```
43
+
44
+
45
+ ### Parameters
46
+
47
+ * `id` (int64): Required - Sftp Host Key ID.
48
+
49
+ ---
50
+
51
+ ## Create Sftp Host Key
52
+
53
+ ```
54
+ await SftpHostKey.create({
55
+ 'name': "",
56
+ 'private_key': "",
57
+ })
58
+ ```
59
+
60
+
61
+ ### Parameters
62
+
63
+ * `name` (string): The friendly name of this SFTP Host Key.
64
+ * `private_key` (string): The private key data.
65
+
66
+ ---
67
+
68
+ ## Update Sftp Host Key
69
+
70
+ ```
71
+ const [sftp_host_key] = await SftpHostKey.list()
72
+
73
+ await sftp_host_key.update({
74
+ 'name': "",
75
+ 'private_key': "",
76
+ })
77
+ ```
78
+
79
+ ### Parameters
80
+
81
+ * `id` (int64): Required - Sftp Host Key ID.
82
+ * `name` (string): The friendly name of this SFTP Host Key.
83
+ * `private_key` (string): The private key data.
84
+
85
+ ### Example Response
86
+
87
+ ```json
88
+ {
89
+ "id": 1,
90
+ "name": "",
91
+ "fingerprint_md5": "",
92
+ "fingerprint_sha256": ""
93
+ }
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Delete Sftp Host Key
99
+
100
+ ```
101
+ const [sftp_host_key] = await SftpHostKey.list()
102
+
103
+ await sftp_host_key.delete()
104
+ ```
105
+
106
+ ### Parameters
107
+
108
+ * `id` (int64): Required - Sftp Host Key ID.
109
+
@@ -359,24 +359,22 @@ var ApiKey = /*#__PURE__*/(0, _createClass2.default)(function ApiKey() {
359
359
  return ApiKey.list(params, options);
360
360
  });
361
361
  (0, _defineProperty2.default)(ApiKey, "findCurrent", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
362
- var params,
363
- options,
362
+ var options,
364
363
  response,
365
364
  _args4 = arguments;
366
365
  return _regenerator.default.wrap(function _callee4$(_context4) {
367
366
  while (1) {
368
367
  switch (_context4.prev = _context4.next) {
369
368
  case 0:
370
- params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
371
- options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
372
- _context4.next = 4;
373
- return _Api.default.sendRequest("/api_key", 'GET', options);
369
+ options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
370
+ _context4.next = 3;
371
+ return _Api.default.sendRequest("/api_key", 'GET', {}, options);
374
372
 
375
- case 4:
373
+ case 3:
376
374
  response = _context4.sent;
377
375
  return _context4.abrupt("return", new ApiKey(response === null || response === void 0 ? void 0 : response.data, options));
378
376
 
379
- case 6:
377
+ case 5:
380
378
  case "end":
381
379
  return _context4.stop();
382
380
  }
@@ -563,24 +561,22 @@ var ApiKey = /*#__PURE__*/(0, _createClass2.default)(function ApiKey() {
563
561
  }, _callee7);
564
562
  })));
565
563
  (0, _defineProperty2.default)(ApiKey, "deleteCurrent", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
566
- var params,
567
- options,
564
+ var options,
568
565
  response,
569
566
  _args8 = arguments;
570
567
  return _regenerator.default.wrap(function _callee8$(_context8) {
571
568
  while (1) {
572
569
  switch (_context8.prev = _context8.next) {
573
570
  case 0:
574
- params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
575
- options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
576
- _context8.next = 4;
577
- return _Api.default.sendRequest("/api_key", 'DELETE', options);
571
+ options = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
572
+ _context8.next = 3;
573
+ return _Api.default.sendRequest("/api_key", 'DELETE', {}, options);
578
574
 
579
- case 4:
575
+ case 3:
580
576
  response = _context8.sent;
581
577
  return _context8.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
582
578
 
583
- case 6:
579
+ case 5:
584
580
  case "end":
585
581
  return _context8.stop();
586
582
  }
@@ -179,24 +179,22 @@ var Session = /*#__PURE__*/(0, _createClass2.default)(function Session() {
179
179
  }, _callee);
180
180
  })));
181
181
  (0, _defineProperty2.default)(Session, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
182
- var params,
183
- options,
182
+ var options,
184
183
  response,
185
184
  _args2 = arguments;
186
185
  return _regenerator.default.wrap(function _callee2$(_context2) {
187
186
  while (1) {
188
187
  switch (_context2.prev = _context2.next) {
189
188
  case 0:
190
- params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
191
- options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
192
- _context2.next = 4;
193
- return _Api.default.sendRequest("/sessions", 'DELETE', options);
189
+ options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
190
+ _context2.next = 3;
191
+ return _Api.default.sendRequest("/sessions", 'DELETE', {}, options);
194
192
 
195
- case 4:
193
+ case 3:
196
194
  response = _context2.sent;
197
195
  return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
198
196
 
199
- case 6:
197
+ case 5:
200
198
  case "end":
201
199
  return _context2.stop();
202
200
  }
@@ -0,0 +1,418 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ exports.__esModule = true;
8
+ exports.default = void 0;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
18
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
+
22
+ var _Api = _interopRequireDefault(require("../Api"));
23
+
24
+ var errors = _interopRequireWildcard(require("../Errors"));
25
+
26
+ var _Logger = _interopRequireDefault(require("../Logger"));
27
+
28
+ var _utils = require("../utils");
29
+
30
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
+
32
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
+
34
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
35
+
36
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
37
+
38
+ /**
39
+ * Class SftpHostKey
40
+ */
41
+ var SftpHostKey = /*#__PURE__*/(0, _createClass2.default)(function SftpHostKey() {
42
+ var _this = this;
43
+
44
+ var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
45
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46
+ (0, _classCallCheck2.default)(this, SftpHostKey);
47
+ (0, _defineProperty2.default)(this, "attributes", {});
48
+ (0, _defineProperty2.default)(this, "options", {});
49
+ (0, _defineProperty2.default)(this, "isLoaded", function () {
50
+ return !!_this.attributes.id;
51
+ });
52
+ (0, _defineProperty2.default)(this, "getId", function () {
53
+ return _this.attributes.id;
54
+ });
55
+ (0, _defineProperty2.default)(this, "setId", function (value) {
56
+ _this.attributes.id = value;
57
+ });
58
+ (0, _defineProperty2.default)(this, "getName", function () {
59
+ return _this.attributes.name;
60
+ });
61
+ (0, _defineProperty2.default)(this, "setName", function (value) {
62
+ _this.attributes.name = value;
63
+ });
64
+ (0, _defineProperty2.default)(this, "getFingerprintMd5", function () {
65
+ return _this.attributes.fingerprint_md5;
66
+ });
67
+ (0, _defineProperty2.default)(this, "setFingerprintMd5", function (value) {
68
+ _this.attributes.fingerprint_md5 = value;
69
+ });
70
+ (0, _defineProperty2.default)(this, "getFingerprintSha256", function () {
71
+ return _this.attributes.fingerprint_sha256;
72
+ });
73
+ (0, _defineProperty2.default)(this, "setFingerprintSha256", function (value) {
74
+ _this.attributes.fingerprint_sha256 = value;
75
+ });
76
+ (0, _defineProperty2.default)(this, "getPrivateKey", function () {
77
+ return _this.attributes.private_key;
78
+ });
79
+ (0, _defineProperty2.default)(this, "setPrivateKey", function (value) {
80
+ _this.attributes.private_key = value;
81
+ });
82
+ (0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
83
+ var params,
84
+ response,
85
+ _args = arguments;
86
+ return _regenerator.default.wrap(function _callee$(_context) {
87
+ while (1) {
88
+ switch (_context.prev = _context.next) {
89
+ case 0:
90
+ params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
91
+
92
+ if (_this.attributes.id) {
93
+ _context.next = 3;
94
+ break;
95
+ }
96
+
97
+ throw new errors.EmptyPropertyError('Current object has no id');
98
+
99
+ case 3:
100
+ if ((0, _utils.isObject)(params)) {
101
+ _context.next = 5;
102
+ break;
103
+ }
104
+
105
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
106
+
107
+ case 5:
108
+ params.id = _this.attributes.id;
109
+
110
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
111
+ _context.next = 8;
112
+ break;
113
+ }
114
+
115
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
116
+
117
+ case 8:
118
+ if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
119
+ _context.next = 10;
120
+ break;
121
+ }
122
+
123
+ throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(name)));
124
+
125
+ case 10:
126
+ if (!(params['private_key'] && !(0, _utils.isString)(params['private_key']))) {
127
+ _context.next = 12;
128
+ break;
129
+ }
130
+
131
+ throw new errors.InvalidParameterError("Bad parameter: private_key must be of type String, received ".concat((0, _utils.getType)(private_key)));
132
+
133
+ case 12:
134
+ if (params['id']) {
135
+ _context.next = 18;
136
+ break;
137
+ }
138
+
139
+ if (!_this.attributes.id) {
140
+ _context.next = 17;
141
+ break;
142
+ }
143
+
144
+ params['id'] = _this.id;
145
+ _context.next = 18;
146
+ break;
147
+
148
+ case 17:
149
+ throw new errors.MissingParameterError('Parameter missing: id');
150
+
151
+ case 18:
152
+ _context.next = 20;
153
+ return _Api.default.sendRequest("/sftp_host_keys/".concat(encodeURIComponent(params['id'])), 'PATCH', params, _this.options);
154
+
155
+ case 20:
156
+ response = _context.sent;
157
+ return _context.abrupt("return", new SftpHostKey(response === null || response === void 0 ? void 0 : response.data, _this.options));
158
+
159
+ case 22:
160
+ case "end":
161
+ return _context.stop();
162
+ }
163
+ }
164
+ }, _callee);
165
+ })));
166
+ (0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
167
+ var params,
168
+ response,
169
+ _args2 = arguments;
170
+ return _regenerator.default.wrap(function _callee2$(_context2) {
171
+ while (1) {
172
+ switch (_context2.prev = _context2.next) {
173
+ case 0:
174
+ params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
175
+
176
+ if (_this.attributes.id) {
177
+ _context2.next = 3;
178
+ break;
179
+ }
180
+
181
+ throw new errors.EmptyPropertyError('Current object has no id');
182
+
183
+ case 3:
184
+ if ((0, _utils.isObject)(params)) {
185
+ _context2.next = 5;
186
+ break;
187
+ }
188
+
189
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
190
+
191
+ case 5:
192
+ params.id = _this.attributes.id;
193
+
194
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
195
+ _context2.next = 8;
196
+ break;
197
+ }
198
+
199
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
200
+
201
+ case 8:
202
+ if (params['id']) {
203
+ _context2.next = 14;
204
+ break;
205
+ }
206
+
207
+ if (!_this.attributes.id) {
208
+ _context2.next = 13;
209
+ break;
210
+ }
211
+
212
+ params['id'] = _this.id;
213
+ _context2.next = 14;
214
+ break;
215
+
216
+ case 13:
217
+ throw new errors.MissingParameterError('Parameter missing: id');
218
+
219
+ case 14:
220
+ _context2.next = 16;
221
+ return _Api.default.sendRequest("/sftp_host_keys/".concat(encodeURIComponent(params['id'])), 'DELETE', params, _this.options);
222
+
223
+ case 16:
224
+ response = _context2.sent;
225
+ return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
226
+
227
+ case 18:
228
+ case "end":
229
+ return _context2.stop();
230
+ }
231
+ }
232
+ }, _callee2);
233
+ })));
234
+ (0, _defineProperty2.default)(this, "destroy", function () {
235
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
236
+ return _this.delete(params);
237
+ });
238
+ (0, _defineProperty2.default)(this, "save", function () {
239
+ if (_this.attributes['id']) {
240
+ return _this.update(_this.attributes);
241
+ } else {
242
+ var newObject = SftpHostKey.create(_this.attributes, _this.options);
243
+ _this.attributes = _objectSpread({}, newObject.attributes);
244
+ return true;
245
+ }
246
+ });
247
+ Object.entries(attributes).forEach(function (_ref3) {
248
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
249
+ key = _ref4[0],
250
+ value = _ref4[1];
251
+
252
+ var normalizedKey = key.replace('?', '');
253
+ _this.attributes[normalizedKey] = value;
254
+ Object.defineProperty(_this, normalizedKey, {
255
+ value: value,
256
+ writable: false
257
+ });
258
+ });
259
+ this.options = _objectSpread({}, options);
260
+ });
261
+ (0, _defineProperty2.default)(SftpHostKey, "list", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
262
+ var _response$data;
263
+
264
+ var params,
265
+ options,
266
+ response,
267
+ _args3 = arguments;
268
+ return _regenerator.default.wrap(function _callee3$(_context3) {
269
+ while (1) {
270
+ switch (_context3.prev = _context3.next) {
271
+ case 0:
272
+ params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
273
+ options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
274
+
275
+ if (!(params['cursor'] && !(0, _utils.isString)(params['cursor']))) {
276
+ _context3.next = 4;
277
+ break;
278
+ }
279
+
280
+ throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params['cursor'])));
281
+
282
+ case 4:
283
+ if (!(params['per_page'] && !(0, _utils.isInt)(params['per_page']))) {
284
+ _context3.next = 6;
285
+ break;
286
+ }
287
+
288
+ throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params['per_page'])));
289
+
290
+ case 6:
291
+ _context3.next = 8;
292
+ return _Api.default.sendRequest("/sftp_host_keys", 'GET', params, options);
293
+
294
+ case 8:
295
+ response = _context3.sent;
296
+ return _context3.abrupt("return", (response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
297
+ return new SftpHostKey(obj, options);
298
+ })) || []);
299
+
300
+ case 10:
301
+ case "end":
302
+ return _context3.stop();
303
+ }
304
+ }
305
+ }, _callee3);
306
+ })));
307
+ (0, _defineProperty2.default)(SftpHostKey, "all", function () {
308
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
309
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
310
+ return SftpHostKey.list(params, options);
311
+ });
312
+ (0, _defineProperty2.default)(SftpHostKey, "find", /*#__PURE__*/function () {
313
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id) {
314
+ var params,
315
+ options,
316
+ response,
317
+ _args4 = arguments;
318
+ return _regenerator.default.wrap(function _callee4$(_context4) {
319
+ while (1) {
320
+ switch (_context4.prev = _context4.next) {
321
+ case 0:
322
+ params = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
323
+ options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
324
+
325
+ if ((0, _utils.isObject)(params)) {
326
+ _context4.next = 4;
327
+ break;
328
+ }
329
+
330
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
331
+
332
+ case 4:
333
+ params['id'] = id;
334
+
335
+ if (params['id']) {
336
+ _context4.next = 7;
337
+ break;
338
+ }
339
+
340
+ throw new errors.MissingParameterError('Parameter missing: id');
341
+
342
+ case 7:
343
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
344
+ _context4.next = 9;
345
+ break;
346
+ }
347
+
348
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params['id'])));
349
+
350
+ case 9:
351
+ _context4.next = 11;
352
+ return _Api.default.sendRequest("/sftp_host_keys/".concat(encodeURIComponent(params['id'])), 'GET', params, options);
353
+
354
+ case 11:
355
+ response = _context4.sent;
356
+ return _context4.abrupt("return", new SftpHostKey(response === null || response === void 0 ? void 0 : response.data, options));
357
+
358
+ case 13:
359
+ case "end":
360
+ return _context4.stop();
361
+ }
362
+ }
363
+ }, _callee4);
364
+ }));
365
+
366
+ return function (_x) {
367
+ return _ref6.apply(this, arguments);
368
+ };
369
+ }());
370
+ (0, _defineProperty2.default)(SftpHostKey, "get", function (id) {
371
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
372
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
373
+ return SftpHostKey.find(id, params, options);
374
+ });
375
+ (0, _defineProperty2.default)(SftpHostKey, "create", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
376
+ var params,
377
+ options,
378
+ response,
379
+ _args5 = arguments;
380
+ return _regenerator.default.wrap(function _callee5$(_context5) {
381
+ while (1) {
382
+ switch (_context5.prev = _context5.next) {
383
+ case 0:
384
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
385
+ options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
386
+
387
+ if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
388
+ _context5.next = 4;
389
+ break;
390
+ }
391
+
392
+ throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(params['name'])));
393
+
394
+ case 4:
395
+ if (!(params['private_key'] && !(0, _utils.isString)(params['private_key']))) {
396
+ _context5.next = 6;
397
+ break;
398
+ }
399
+
400
+ throw new errors.InvalidParameterError("Bad parameter: private_key must be of type String, received ".concat((0, _utils.getType)(params['private_key'])));
401
+
402
+ case 6:
403
+ _context5.next = 8;
404
+ return _Api.default.sendRequest("/sftp_host_keys", 'POST', params, options);
405
+
406
+ case 8:
407
+ response = _context5.sent;
408
+ return _context5.abrupt("return", new SftpHostKey(response === null || response === void 0 ? void 0 : response.data, options));
409
+
410
+ case 10:
411
+ case "end":
412
+ return _context5.stop();
413
+ }
414
+ }
415
+ }, _callee5);
416
+ })));
417
+ var _default = SftpHostKey;
418
+ exports.default = _default;
@@ -460,24 +460,22 @@ var Site = /*#__PURE__*/(0, _createClass2.default)(function Site() {
460
460
  this.options = _objectSpread({}, options);
461
461
  });
462
462
  (0, _defineProperty2.default)(Site, "get", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
463
- var params,
464
- options,
463
+ var options,
465
464
  response,
466
465
  _args = arguments;
467
466
  return _regenerator.default.wrap(function _callee$(_context) {
468
467
  while (1) {
469
468
  switch (_context.prev = _context.next) {
470
469
  case 0:
471
- params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
472
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
473
- _context.next = 4;
474
- return _Api.default.sendRequest("/site", 'GET', options);
470
+ options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
471
+ _context.next = 3;
472
+ return _Api.default.sendRequest("/site", 'GET', {}, options);
475
473
 
476
- case 4:
474
+ case 3:
477
475
  response = _context.sent;
478
476
  return _context.abrupt("return", new Site(response === null || response === void 0 ? void 0 : response.data, options));
479
477
 
480
- case 6:
478
+ case 5:
481
479
  case "end":
482
480
  return _context.stop();
483
481
  }
@@ -485,24 +483,22 @@ var Site = /*#__PURE__*/(0, _createClass2.default)(function Site() {
485
483
  }, _callee);
486
484
  })));
487
485
  (0, _defineProperty2.default)(Site, "getUsage", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
488
- var params,
489
- options,
486
+ var options,
490
487
  response,
491
488
  _args2 = arguments;
492
489
  return _regenerator.default.wrap(function _callee2$(_context2) {
493
490
  while (1) {
494
491
  switch (_context2.prev = _context2.next) {
495
492
  case 0:
496
- params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
497
- options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
498
- _context2.next = 4;
499
- return _Api.default.sendRequest("/site/usage", 'GET', options);
493
+ options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
494
+ _context2.next = 3;
495
+ return _Api.default.sendRequest("/site/usage", 'GET', {}, options);
500
496
 
501
- case 4:
497
+ case 3:
502
498
  response = _context2.sent;
503
499
  return _context2.abrupt("return", new UsageSnapshot(response === null || response === void 0 ? void 0 : response.data, options));
504
500
 
505
- case 6:
501
+ case 5:
506
502
  case "end":
507
503
  return _context2.stop();
508
504
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.214",
3
+ "version": "1.0.216",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
@@ -209,8 +209,8 @@ class ApiKey {
209
209
  static all = (params = {}, options = {}) =>
210
210
  ApiKey.list(params, options)
211
211
 
212
- static findCurrent = async (params = {}, options = {}) => {
213
- const response = await Api.sendRequest(`/api_key`, 'GET', options)
212
+ static findCurrent = async (options = {}) => {
213
+ const response = await Api.sendRequest(`/api_key`, 'GET', {}, options)
214
214
 
215
215
  return new ApiKey(response?.data, options)
216
216
  }
@@ -294,8 +294,8 @@ class ApiKey {
294
294
  return new ApiKey(response?.data, options)
295
295
  }
296
296
 
297
- static deleteCurrent = async (params = {}, options = {}) => {
298
- const response = await Api.sendRequest(`/api_key`, 'DELETE', options)
297
+ static deleteCurrent = async (options = {}) => {
298
+ const response = await Api.sendRequest(`/api_key`, 'DELETE', {}, options)
299
299
 
300
300
  return response?.data
301
301
  }
@@ -117,8 +117,8 @@ class Session {
117
117
  return new Session(response?.data, options)
118
118
  }
119
119
 
120
- static delete = async (params = {}, options = {}) => {
121
- const response = await Api.sendRequest(`/sessions`, 'DELETE', options)
120
+ static delete = async (options = {}) => {
121
+ const response = await Api.sendRequest(`/sessions`, 'DELETE', {}, options)
122
122
 
123
123
  return response?.data
124
124
  }
@@ -0,0 +1,201 @@
1
+ import Api from '../Api'
2
+ import * as errors from '../Errors'
3
+ import Logger from '../Logger'
4
+ import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
5
+
6
+ /**
7
+ * Class SftpHostKey
8
+ */
9
+ class SftpHostKey {
10
+ attributes = {}
11
+ options = {}
12
+
13
+ constructor(attributes = {}, options = {}) {
14
+ Object.entries(attributes).forEach(([key, value]) => {
15
+ const normalizedKey = key.replace('?', '')
16
+
17
+ this.attributes[normalizedKey] = value
18
+
19
+ Object.defineProperty(this, normalizedKey, { value, writable: false })
20
+ })
21
+
22
+ this.options = { ...options }
23
+ }
24
+
25
+ isLoaded = () => !!this.attributes.id
26
+ // int64 # Sftp Host Key ID
27
+ getId = () => this.attributes.id
28
+
29
+ setId = value => {
30
+ this.attributes.id = value
31
+ }
32
+
33
+ // string # The friendly name of this SFTP Host Key.
34
+ getName = () => this.attributes.name
35
+
36
+ setName = value => {
37
+ this.attributes.name = value
38
+ }
39
+
40
+ // string # MD5 Fingerpint of the public key
41
+ getFingerprintMd5 = () => this.attributes.fingerprint_md5
42
+
43
+ setFingerprintMd5 = value => {
44
+ this.attributes.fingerprint_md5 = value
45
+ }
46
+
47
+ // string # SHA256 Fingerpint of the public key
48
+ getFingerprintSha256 = () => this.attributes.fingerprint_sha256
49
+
50
+ setFingerprintSha256 = value => {
51
+ this.attributes.fingerprint_sha256 = value
52
+ }
53
+
54
+ // string # The private key data.
55
+ getPrivateKey = () => this.attributes.private_key
56
+
57
+ setPrivateKey = value => {
58
+ this.attributes.private_key = value
59
+ }
60
+
61
+
62
+ // Parameters:
63
+ // name - string - The friendly name of this SFTP Host Key.
64
+ // private_key - string - The private key data.
65
+ update = async (params = {}) => {
66
+ if (!this.attributes.id) {
67
+ throw new errors.EmptyPropertyError('Current object has no id')
68
+ }
69
+
70
+ if (!isObject(params)) {
71
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
72
+ }
73
+
74
+ params.id = this.attributes.id
75
+ if (params['id'] && !isInt(params['id'])) {
76
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
77
+ }
78
+ if (params['name'] && !isString(params['name'])) {
79
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(name)}`)
80
+ }
81
+ if (params['private_key'] && !isString(params['private_key'])) {
82
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(private_key)}`)
83
+ }
84
+
85
+ if (!params['id']) {
86
+ if (this.attributes.id) {
87
+ params['id'] = this.id
88
+ } else {
89
+ throw new errors.MissingParameterError('Parameter missing: id')
90
+ }
91
+ }
92
+
93
+ const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
94
+
95
+ return new SftpHostKey(response?.data, this.options)
96
+ }
97
+
98
+ delete = async (params = {}) => {
99
+ if (!this.attributes.id) {
100
+ throw new errors.EmptyPropertyError('Current object has no id')
101
+ }
102
+
103
+ if (!isObject(params)) {
104
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
105
+ }
106
+
107
+ params.id = this.attributes.id
108
+ if (params['id'] && !isInt(params['id'])) {
109
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
110
+ }
111
+
112
+ if (!params['id']) {
113
+ if (this.attributes.id) {
114
+ params['id'] = this.id
115
+ } else {
116
+ throw new errors.MissingParameterError('Parameter missing: id')
117
+ }
118
+ }
119
+
120
+ const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
121
+
122
+ return response?.data
123
+ }
124
+
125
+ destroy = (params = {}) =>
126
+ this.delete(params)
127
+
128
+ save = () => {
129
+ if (this.attributes['id']) {
130
+ return this.update(this.attributes)
131
+ } else {
132
+ const newObject = SftpHostKey.create(this.attributes, this.options)
133
+ this.attributes = { ...newObject.attributes }
134
+ return true
135
+ }
136
+ }
137
+
138
+ // Parameters:
139
+ // cursor - string - Used for pagination. Send a cursor value to resume an existing list from the point at which you left off. Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
140
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
141
+ static list = async (params = {}, options = {}) => {
142
+ if (params['cursor'] && !isString(params['cursor'])) {
143
+ throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
144
+ }
145
+
146
+ if (params['per_page'] && !isInt(params['per_page'])) {
147
+ throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
148
+ }
149
+
150
+ const response = await Api.sendRequest(`/sftp_host_keys`, 'GET', params, options)
151
+
152
+ return response?.data?.map(obj => new SftpHostKey(obj, options)) || []
153
+ }
154
+
155
+ static all = (params = {}, options = {}) =>
156
+ SftpHostKey.list(params, options)
157
+
158
+ // Parameters:
159
+ // id (required) - int64 - Sftp Host Key ID.
160
+ static find = async (id, params = {}, options = {}) => {
161
+ if (!isObject(params)) {
162
+ throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
163
+ }
164
+
165
+ params['id'] = id
166
+
167
+ if (!params['id']) {
168
+ throw new errors.MissingParameterError('Parameter missing: id')
169
+ }
170
+
171
+ if (params['id'] && !isInt(params['id'])) {
172
+ throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
173
+ }
174
+
175
+ const response = await Api.sendRequest(`/sftp_host_keys/${encodeURIComponent(params['id'])}`, 'GET', params, options)
176
+
177
+ return new SftpHostKey(response?.data, options)
178
+ }
179
+
180
+ static get = (id, params = {}, options = {}) =>
181
+ SftpHostKey.find(id, params, options)
182
+
183
+ // Parameters:
184
+ // name - string - The friendly name of this SFTP Host Key.
185
+ // private_key - string - The private key data.
186
+ static create = async (params = {}, options = {}) => {
187
+ if (params['name'] && !isString(params['name'])) {
188
+ throw new errors.InvalidParameterError(`Bad parameter: name must be of type String, received ${getType(params['name'])}`)
189
+ }
190
+
191
+ if (params['private_key'] && !isString(params['private_key'])) {
192
+ throw new errors.InvalidParameterError(`Bad parameter: private_key must be of type String, received ${getType(params['private_key'])}`)
193
+ }
194
+
195
+ const response = await Api.sendRequest(`/sftp_host_keys`, 'POST', params, options)
196
+
197
+ return new SftpHostKey(response?.data, options)
198
+ }
199
+ }
200
+
201
+ export default SftpHostKey
@@ -420,14 +420,14 @@ class Site {
420
420
  getDisableUsersFromInactivityPeriodDays = () => this.attributes.disable_users_from_inactivity_period_days
421
421
 
422
422
 
423
- static get = async (params = {}, options = {}) => {
424
- const response = await Api.sendRequest(`/site`, 'GET', options)
423
+ static get = async (options = {}) => {
424
+ const response = await Api.sendRequest(`/site`, 'GET', {}, options)
425
425
 
426
426
  return new Site(response?.data, options)
427
427
  }
428
428
 
429
- static getUsage = async (params = {}, options = {}) => {
430
- const response = await Api.sendRequest(`/site/usage`, 'GET', options)
429
+ static getUsage = async (options = {}) => {
430
+ const response = await Api.sendRequest(`/site/usage`, 'GET', {}, options)
431
431
 
432
432
  return new UsageSnapshot(response?.data, options)
433
433
  }