@bitbar/cloud-api-client 0.55.0 → 1.0.0

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.
Files changed (157) hide show
  1. package/dist/API.d.ts +66 -38
  2. package/dist/ApiConfig.d.ts +10 -10
  3. package/dist/CloudAPIClient.d.ts +7 -7
  4. package/dist/Filter.d.ts +7 -7
  5. package/dist/FilterBuilder.d.ts +24 -25
  6. package/dist/api/APIAdminListDevices.d.ts +12 -12
  7. package/dist/api/APIAdminListNotificationPlans.d.ts +11 -7
  8. package/dist/api/APIAdminListRuns.d.ts +14 -7
  9. package/dist/api/APIAdminListServices.d.ts +11 -12
  10. package/dist/api/APIAdminListStatistics.d.ts +10 -7
  11. package/dist/api/APIAdminResource.d.ts +121 -91
  12. package/dist/api/APIAdminResourceAccount.d.ts +8 -5
  13. package/dist/api/APIAdminResourceAccountService.d.ts +10 -7
  14. package/dist/api/APIAdminResourceCluster.d.ts +11 -7
  15. package/dist/api/APIAdminResourceDevice.d.ts +16 -11
  16. package/dist/api/APIAdminResourceDeviceModel.d.ts +11 -7
  17. package/dist/api/APIAdminResourceDeviceSession.d.ts +5 -5
  18. package/dist/api/APIAdminResourceDeviceSessionStandalone.d.ts +6 -12
  19. package/dist/api/APIAdminResourceDeviceTime.d.ts +12 -8
  20. package/dist/api/APIAdminResourceFramework.d.ts +13 -8
  21. package/dist/api/APIAdminResourceLicense.d.ts +12 -9
  22. package/dist/api/APIAdminResourceNotificationPlan.d.ts +13 -9
  23. package/dist/api/APIAdminResourceProject.d.ts +7 -6
  24. package/dist/api/APIAdminResourceRun.d.ts +8 -7
  25. package/dist/api/APIAdminResourceRunStandalone.d.ts +12 -13
  26. package/dist/api/APIAdminResourceService.d.ts +9 -9
  27. package/dist/api/APIAdminResourceUser.d.ts +18 -12
  28. package/dist/api/APIAdminResourceUserAccount.d.ts +15 -10
  29. package/dist/api/APIEntity.d.ts +35 -32
  30. package/dist/api/APIList.d.ts +22 -24
  31. package/dist/api/APIListCleanupConfigurations.d.ts +11 -7
  32. package/dist/api/APIListDeviceTime.d.ts +11 -7
  33. package/dist/api/APIListDevices.d.ts +13 -12
  34. package/dist/api/APIListFiles.d.ts +11 -10
  35. package/dist/api/APIListNotifications.d.ts +13 -7
  36. package/dist/api/APIListProperties.d.ts +10 -6
  37. package/dist/api/APIListRuns.d.ts +10 -7
  38. package/dist/api/APIListServices.d.ts +16 -9
  39. package/dist/api/APIListSmartbearTunnels.d.ts +11 -6
  40. package/dist/api/APIListUsers.d.ts +17 -11
  41. package/dist/api/APIResource.d.ts +6 -5
  42. package/dist/api/APIResourceAccessGroup.d.ts +16 -10
  43. package/dist/api/APIResourceAccount.d.ts +12 -7
  44. package/dist/api/APIResourceAccountService.d.ts +11 -6
  45. package/dist/api/APIResourceAdditionalUser.d.ts +9 -6
  46. package/dist/api/APIResourceBillingPeriod.d.ts +9 -6
  47. package/dist/api/APIResourceBroker.d.ts +10 -0
  48. package/dist/api/APIResourceChannel.d.ts +8 -0
  49. package/dist/api/APIResourceCleanupConfiguration.d.ts +9 -7
  50. package/dist/api/APIResourceDevice.d.ts +12 -7
  51. package/dist/api/APIResourceDeviceGroup.d.ts +18 -11
  52. package/dist/api/APIResourceDeviceSession.d.ts +9 -8
  53. package/dist/api/APIResourceDeviceSessionCommon.d.ts +26 -18
  54. package/dist/api/APIResourceDeviceSessionStandalone.d.ts +19 -14
  55. package/dist/api/APIResourceFile.d.ts +17 -9
  56. package/dist/api/APIResourceLabelGroup.d.ts +12 -8
  57. package/dist/api/APIResourceNotification.d.ts +10 -6
  58. package/dist/api/APIResourceProject.d.ts +15 -15
  59. package/dist/api/APIResourceRun.d.ts +6 -6
  60. package/dist/api/APIResourceRunCommon.d.ts +29 -19
  61. package/dist/api/APIResourceUser.d.ts +69 -56
  62. package/dist/api/APIResourceUserSession.d.ts +12 -9
  63. package/dist/api/APIUserResourceAccount.d.ts +16 -10
  64. package/dist/api/class/FilesQueryParams.d.ts +4 -0
  65. package/dist/api/class/Images.filter.d.ts +2 -0
  66. package/dist/api/class/InputFileset.d.ts +13 -8
  67. package/dist/api/class/NonMedia.filter.d.ts +2 -0
  68. package/dist/api/class/OutputFileset.d.ts +21 -14
  69. package/dist/api/decorators/NonRequestable.d.ts +8 -0
  70. package/dist/api/factory/postAdminDeviceSessionChangeBillable.d.ts +5 -4
  71. package/dist/api/factory/postDeviceRunIds.d.ts +5 -4
  72. package/dist/api/interface/DeviceSession.d.ts +8 -7
  73. package/dist/api/interface/DeviceSessionBase.d.ts +8 -8
  74. package/dist/api/interface/DeviceSessionCommon.d.ts +17 -13
  75. package/dist/api/interface/DeviceSessionStandalone.d.ts +11 -9
  76. package/dist/api/models/AccessGroup.d.ts +14 -0
  77. package/dist/api/models/Account.d.ts +7 -0
  78. package/dist/api/models/AccountConcurrencyStatusMap.d.ts +4 -0
  79. package/dist/api/models/AccountPreference.d.ts +4 -0
  80. package/dist/api/models/AccountService.d.ts +66 -0
  81. package/dist/api/models/AccountServicePayment.d.ts +11 -0
  82. package/dist/api/models/Activity.d.ts +13 -0
  83. package/dist/api/models/AdminDevice.d.ts +50 -0
  84. package/dist/api/models/AdminDeviceSession.d.ts +36 -0
  85. package/dist/api/models/AdminDeviceSessionStatistics.d.ts +22 -0
  86. package/dist/api/models/AdminDeviceType.d.ts +12 -0
  87. package/dist/api/models/AdminEmail.d.ts +9 -0
  88. package/dist/api/models/AdminError.d.ts +39 -0
  89. package/dist/api/models/AdminFrameworkStatistics.d.ts +24 -0
  90. package/dist/api/models/AdminOverview.d.ts +10 -0
  91. package/dist/api/models/AdminTestRun.d.ts +31 -0
  92. package/dist/api/models/BillingPeriod.d.ts +40 -0
  93. package/dist/api/models/Broker.d.ts +10 -0
  94. package/dist/api/models/Browser.d.ts +15 -0
  95. package/dist/api/models/CleanupConfiguration.d.ts +5 -0
  96. package/dist/api/models/Cluster.d.ts +32 -0
  97. package/dist/api/models/Connection.d.ts +15 -0
  98. package/dist/api/models/CountryVatRate.d.ts +7 -0
  99. package/dist/api/models/DesktopBrowserCapabilities.d.ts +19 -0
  100. package/dist/api/models/Device.d.ts +108 -0
  101. package/dist/api/models/DeviceFilter.d.ts +17 -0
  102. package/dist/api/models/DeviceGroup.d.ts +30 -0
  103. package/dist/api/models/DeviceModel.d.ts +23 -0
  104. package/dist/api/models/DeviceModelCriterion.d.ts +19 -0
  105. package/dist/api/models/DeviceModelPool.d.ts +19 -0
  106. package/dist/api/models/DeviceProblem.d.ts +23 -0
  107. package/dist/api/models/DeviceSession.d.ts +137 -0
  108. package/dist/api/models/DeviceSessionDataAvailability.d.ts +9 -0
  109. package/dist/api/models/DeviceStatistics.d.ts +15 -0
  110. package/dist/api/models/DeviceStatus.d.ts +30 -0
  111. package/dist/api/models/DeviceTimeCountSessionReportEntry.d.ts +12 -0
  112. package/dist/api/models/DeviceTimeStepTimeReportEntry.d.ts +12 -0
  113. package/dist/api/models/DeviceUsage.d.ts +7 -0
  114. package/dist/api/models/Enum.d.ts +10 -0
  115. package/dist/api/models/Framework.d.ts +37 -0
  116. package/dist/api/models/HTTP.d.ts +33 -0
  117. package/dist/api/models/LabelGroup.d.ts +7 -0
  118. package/dist/api/models/License.d.ts +74 -0
  119. package/dist/api/models/Maintenance.d.ts +13 -0
  120. package/dist/api/models/Message.d.ts +3 -0
  121. package/dist/api/models/Notification.d.ts +34 -0
  122. package/dist/api/models/NotificationPlan.d.ts +20 -0
  123. package/dist/api/models/Project.d.ts +31 -0
  124. package/dist/api/models/ProjectJobConfig.d.ts +9 -0
  125. package/dist/api/models/Property.d.ts +17 -0
  126. package/dist/api/models/Role.d.ts +15 -0
  127. package/dist/api/models/Screenshot.d.ts +22 -0
  128. package/dist/api/models/Service.d.ts +61 -0
  129. package/dist/api/models/Settings.d.ts +6 -0
  130. package/dist/api/models/SharedResource.d.ts +11 -0
  131. package/dist/api/models/SmartbearTunnel.d.ts +20 -0
  132. package/dist/api/models/Tag.d.ts +16 -0
  133. package/dist/api/models/TestCaseRun.d.ts +40 -0
  134. package/dist/api/models/TestRun.d.ts +132 -0
  135. package/dist/api/models/TestRunDataAvailability.d.ts +10 -0
  136. package/dist/api/models/User.d.ts +75 -0
  137. package/dist/api/models/UserDeviceTime.d.ts +21 -0
  138. package/dist/api/models/UserDeviceTimeSummary.d.ts +14 -0
  139. package/dist/api/models/UserFile.d.ts +65 -0
  140. package/dist/api/models/UserPreference.d.ts +11 -0
  141. package/dist/api/models/UserStatistics.d.ts +14 -0
  142. package/dist/api/models/VatRate.d.ts +4 -0
  143. package/dist/bitbar-cloud-api-client.js +1787 -1732
  144. package/dist/bitbar-cloud-api-client.js.map +1 -1
  145. package/dist/bitbar-cloud-api-client.min.js +17 -2
  146. package/dist/bitbar-cloud-api-client.min.js.map +1 -1
  147. package/dist/finka.d.ts +2 -2
  148. package/dist/index.d.ts +2 -2
  149. package/package.json +32 -28
  150. package/.nycrc +0 -14
  151. package/Jenkinsfile.sonar +0 -53
  152. package/dist/api/APIListPurchased.d.ts +0 -5
  153. package/dist/api/APIListStatistics.d.ts +0 -6
  154. package/dist/api/APIResourceBuild.d.ts +0 -8
  155. package/dist/api/APIResourceJob.d.ts +0 -9
  156. package/sonar-project.properties +0 -17
  157. package/tsconfig.test.json +0 -20
@@ -1,1851 +1,1906 @@
1
- /* @bitbar/cloud-api-client v0.55.0 | Copyright 2021 (c) SmartBear Software and contributors | .git/blob/master/LICENSE */
1
+ /* @bitbar/cloud-api-client v1.0.0 | Copyright 2022 (c) SmartBear Software and contributors | .git/blob/master/LICENSE */
2
2
  (function (global, factory) {
3
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@bitbar/finka'), require('axios'), require('qs')) :
4
- typeof define === 'function' && define.amd ? define(['@bitbar/finka', 'axios', 'qs'], factory) :
5
- (global = global || self, global['bitbar-cloud-api-client'] = factory(global['@bitbar/finka'], global.axios, global.qs));
6
- }(this, (function (finka, axios, qs) { 'use strict';
7
-
8
- finka = finka && Object.prototype.hasOwnProperty.call(finka, 'default') ? finka['default'] : finka;
9
- axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
10
- qs = qs && Object.prototype.hasOwnProperty.call(qs, 'default') ? qs['default'] : qs;
11
-
12
- finka();
13
-
14
- var version = "0.55.0";
15
-
16
- var ALLOWED_HTTP_METHODS;
17
- (function (ALLOWED_HTTP_METHODS) {
18
- ALLOWED_HTTP_METHODS["GET"] = "GET";
19
- ALLOWED_HTTP_METHODS["POST"] = "POST";
20
- ALLOWED_HTTP_METHODS["DELETE"] = "DELETE";
21
- })(ALLOWED_HTTP_METHODS || (ALLOWED_HTTP_METHODS = {}));
22
- class APIEntity {
23
- constructor(parent) {
24
- this.stack = [];
25
- this.requestConfig = {};
26
- if (parent instanceof APIEntity) {
27
- this.root = parent.root;
28
- if (Array.isArray(parent.stack)) {
29
- this.push(...parent.stack);
30
- }
31
- if (parent.requestConfig != null) {
32
- this.setRequestConfig(parent.requestConfig);
33
- }
34
- }
35
- else {
36
- this.root = parent;
37
- }
38
- }
39
- push(...items) {
40
- for (const item of items) {
41
- this.stack.push(item);
42
- }
43
- return this;
44
- }
45
- pop() {
46
- this.stack.pop();
47
- return this;
48
- }
49
- shift() {
50
- this.stack.shift();
51
- return this;
52
- }
53
- unshift(...items) {
54
- for (const item of items) {
55
- this.stack.unshift(item);
56
- }
57
- return this;
58
- }
59
- restack(...items) {
60
- this.stack = items;
61
- return this;
62
- }
63
- get first() {
64
- return this.stack[0];
65
- }
66
- set first(val) {
67
- this.stack[0] = val;
68
- }
69
- get last() {
70
- return this.stack[this.stack.length - 1];
71
- }
72
- set last(val) {
73
- this.stack[this.stack.length - 1] = val;
74
- }
75
- toUrl(absolute = false) {
76
- let url = `/${this.stack.join('/')}`;
77
- if (absolute) {
78
- url = this.root.axiosConfig.baseURL + url;
79
- }
80
- return url;
81
- }
82
- setRequestConfig(requestConfig) {
83
- Object.deepAssign(this.requestConfig, requestConfig);
84
- return this;
85
- }
86
- removeRequestConfig(key) {
87
- delete this.requestConfig[key];
88
- return this;
89
- }
90
- headers(headers) {
91
- const _headers = {};
92
- for (const key in headers) {
93
- const newKey = key.replace(/(?:^|-)([a-z])/g, (letter) => letter.toUpperCase());
94
- _headers[newKey] = headers[key];
95
- }
96
- return this.setRequestConfig({
97
- headers: _headers
98
- });
99
- }
100
- method(name) {
101
- const NAME = name.toLocaleUpperCase();
102
- if (!ALLOWED_HTTP_METHODS[NAME]) {
103
- throw new Error(`Method '${NAME}' is not allowed! You can use: ${Object.keys(ALLOWED_HTTP_METHODS).join(', ')}`);
104
- }
105
- return this.setRequestConfig({
106
- method: NAME
107
- });
108
- }
109
- get() {
110
- return this.method('GET');
111
- }
112
- post() {
113
- return this.method('POST');
114
- }
115
- params(params) {
116
- Object.deepAssign(this.requestConfig, {
117
- params
118
- });
119
- return this;
120
- }
121
- getParams() {
122
- return this.requestConfig.params == null ? {} : this.requestConfig.params;
123
- }
124
- removeParam(key) {
125
- delete this.requestConfig.params[key];
126
- return this;
127
- }
128
- data(data) {
129
- Object.deepAssign(this.requestConfig, {
130
- data
131
- });
132
- return this;
133
- }
134
- jsonData(data) {
135
- this.headers({
136
- 'Content-Type': 'application/json'
137
- }).data(data);
138
- return this;
139
- }
140
- formData(data) {
141
- this.headers({
142
- 'Content-Type': 'multipart/form-data'
143
- }).data(data);
144
- return this;
145
- }
146
- paramsSerializer(params) {
147
- return qs.stringify(params, {
148
- arrayFormat: 'brackets'
149
- });
150
- }
151
- send() {
152
- const requestConfig = Object.deepAssign({}, this.requestConfig, {
153
- url: `/${this.stack.join('/')}`
154
- });
155
- if (requestConfig.headers == null) {
156
- requestConfig.headers = {};
157
- }
158
- if (requestConfig.headers['Content-Type'] == null) {
159
- requestConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
160
- }
161
- if (requestConfig.method === 'POST' &&
162
- requestConfig.headers['Content-Type'].startsWith('application/x-www-form-urlencoded') &&
163
- requestConfig.data != null) {
164
- requestConfig.data = qs.stringify(requestConfig.data, {
165
- arrayFormat: 'brackets'
166
- });
167
- }
168
- if (requestConfig.params) {
169
- requestConfig.paramsSerializer = this.paramsSerializer;
170
- }
171
- return this.root.axios.request(requestConfig);
172
- }
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('axios'), require('@bitbar/finka'), require('qs'), require('node-abort-controller')) :
4
+ typeof define === 'function' && define.amd ? define(['axios', '@bitbar/finka', 'qs', 'node-abort-controller'], factory) :
5
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["bitbar-cloud-api-client"] = factory(global.axios, global["@bitbar/finka"], global.qs, global["node-abort-controller"]));
6
+ })(this, (function (axios, finka, qs, nodeAbortController) { 'use strict';
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
11
+ var finka__default = /*#__PURE__*/_interopDefaultLegacy(finka);
12
+
13
+ var version = "1.0.0";
14
+
15
+ /******************************************************************************
16
+ Copyright (c) Microsoft Corporation.
17
+
18
+ Permission to use, copy, modify, and/or distribute this software for any
19
+ purpose with or without fee is hereby granted.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
+ PERFORMANCE OF THIS SOFTWARE.
28
+ ***************************************************************************** */
29
+
30
+ function __decorate(decorators, target, key, desc) {
31
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
32
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
33
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
34
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
173
35
  }
174
36
 
175
- class Filter {
176
- constructor(name, value, operand) {
177
- this.name = name;
178
- this.value = value;
179
- this.operand = operand;
180
- }
37
+ class Filter {
38
+ constructor(name, value, operand) {
39
+ this.name = name;
40
+ this.value = value;
41
+ this.operand = operand;
42
+ }
181
43
  }
182
44
 
183
- class FilterBuilder {
184
- constructor() {
185
- this.filters = [];
186
- }
187
- add(name, value, operand, checkNull = false) {
188
- value = Array.wrap(value);
189
- if (value.length === 0) {
190
- return this;
191
- }
192
- for (let i = 0; i < value.length; i++) {
193
- const v = value[i];
194
- if (typeof v === 'object' && v instanceof Date) {
195
- value[i] = v.getTime();
196
- }
197
- }
198
- if (checkNull) {
199
- for (const v of value) {
200
- if (v !== null) {
201
- continue;
202
- }
203
- }
204
- }
205
- if (operand.endsWith('ornull') && value.length === 0) {
206
- operand = 'isnull';
207
- }
208
- this.filters.push(new Filter(name, value, operand));
209
- return this;
210
- }
211
- gt(name, value) {
212
- return this.add(name, value, 'gt');
213
- }
214
- lt(name, value) {
215
- return this.add(name, value, 'lt');
216
- }
217
- after(name, value) {
218
- return this.add(name, value, 'after', true);
219
- }
220
- afterorequal(name, value) {
221
- return this.add(name, value, 'afterorequal', true);
222
- }
223
- before(name, value) {
224
- return this.add(name, value, 'before', true);
225
- }
226
- beforeorequal(name, value) {
227
- return this.add(name, value, 'beforeorequal', true);
228
- }
229
- on(name, value) {
230
- return this.add(name, value, 'on');
231
- }
232
- eq(name, value) {
233
- return this.add(name, value, 'eq');
234
- }
235
- contains(name, value) {
236
- return this.add(name, value, 'contains');
237
- }
238
- like(name, value) {
239
- return this.add(name, value, 'like');
240
- }
241
- notlike(name, value) {
242
- return this.add(name, value, 'notlike');
243
- }
244
- isnull(name) {
245
- return this.add(name, undefined, 'isnull');
246
- }
247
- in(name, value) {
248
- return this.add(name, value, 'in', true);
249
- }
250
- notin(name, value) {
251
- return this.add(name, value, 'notin', true);
252
- }
253
- raw(filter) {
254
- const filters = Array.wrap(filter);
255
- for (const filter of filters) {
256
- if (this.isFilterPart(filter)) {
257
- this.filters.push(filter);
258
- }
259
- else {
260
- throw new SyntaxError(`Filter ${filter} has invalid syntax`);
261
- }
262
- }
263
- }
264
- isFilterPart(str) {
265
- return /^[a-zA-Z0-9.]{2,12}_(?:isnull$|(?:gt|lt|(?:after|before)(?:orequal)?|on|eq|contains|like|(?:not)?in)_)/.test(str);
266
- }
267
- toString() {
268
- const parts = [];
269
- let part, val;
270
- for (const filter of this.filters) {
271
- if (typeof filter === 'string') {
272
- part = filter;
273
- }
274
- else {
275
- val = '';
276
- if (filter.value.length > 1 || typeof filter.value[0] !== 'undefined') {
277
- val = `_${filter.value.join('|')}`;
278
- }
279
- part = `${filter.name}_${filter.operand}${val}`;
280
- }
281
- parts.push(part);
282
- }
283
- return parts.join(';');
284
- }
45
+ finka__default["default"]();
46
+
47
+ class FilterBuilder {
48
+ constructor() {
49
+ this.filters = [];
50
+ }
51
+ gt(name, value) {
52
+ return this.add(name, value, 'gt');
53
+ }
54
+ lt(name, value) {
55
+ return this.add(name, value, 'lt');
56
+ }
57
+ after(name, value) {
58
+ return this.add(name, value, 'after', true);
59
+ }
60
+ afterorequal(name, value) {
61
+ return this.add(name, value, 'afterorequal', true);
62
+ }
63
+ before(name, value) {
64
+ return this.add(name, value, 'before', true);
65
+ }
66
+ beforeorequal(name, value) {
67
+ return this.add(name, value, 'beforeorequal', true);
68
+ }
69
+ on(name, value) {
70
+ return this.add(name, value, 'on');
71
+ }
72
+ eq(name, value) {
73
+ return this.add(name, value, 'eq');
74
+ }
75
+ contains(name, value) {
76
+ return this.add(name, value, 'contains');
77
+ }
78
+ like(name, value) {
79
+ return this.add(name, value, 'like');
80
+ }
81
+ notlike(name, value) {
82
+ return this.add(name, value, 'notlike');
83
+ }
84
+ isnull(name) {
85
+ return this.add(name, undefined, 'isnull');
86
+ }
87
+ in(name, value) {
88
+ return this.add(name, value, 'in', true);
89
+ }
90
+ notin(name, value) {
91
+ return this.add(name, value, 'notin', true);
92
+ }
93
+ raw(filter) {
94
+ const filters = Array.wrap(filter);
95
+ for (const filter of filters) {
96
+ if (this.isFilterPart(filter)) {
97
+ this.filters.push(filter);
98
+ }
99
+ else {
100
+ throw new SyntaxError(`Filter ${filter} has invalid syntax`);
101
+ }
102
+ }
103
+ }
104
+ isFilterPart(str) {
105
+ return /^[a-zA-Z0-9.]{2,12}_(?:isnull$|(?:gt|lt|(?:after|before)(?:orequal)?|on|eq|contains|like|(?:not)?in)_)/.test(str);
106
+ }
107
+ toString() {
108
+ const parts = [];
109
+ let part, val;
110
+ for (const filter of this.filters) {
111
+ if (typeof filter === 'string') {
112
+ part = filter;
113
+ }
114
+ else {
115
+ val = '';
116
+ if (filter.value.length > 1 || typeof filter.value[0] !== 'undefined') {
117
+ val = `_${filter.value.join('|')}`;
118
+ }
119
+ part = `${filter.name}_${filter.operand}${val}`;
120
+ }
121
+ parts.push(part);
122
+ }
123
+ return parts.join(';');
124
+ }
125
+ add(name, value, operand, checkNull = false) {
126
+ let _value = Array.wrap(value);
127
+ if (_value.length === 0) {
128
+ return this;
129
+ }
130
+ for (let i = 0; i < _value.length; i++) {
131
+ const v = _value[i];
132
+ if (typeof v === 'object' && v instanceof Date) {
133
+ _value[i] = v.getTime();
134
+ }
135
+ }
136
+ let isNull = false;
137
+ if (checkNull) {
138
+ for (const v of _value) {
139
+ if (v !== null) {
140
+ continue;
141
+ }
142
+ isNull = true;
143
+ }
144
+ if (isNull) {
145
+ _value = _value.filter((item) => item !== null);
146
+ operand += 'ornull';
147
+ }
148
+ }
149
+ if (operand.endsWith('ornull') && _value.length === 0) {
150
+ operand = 'isnull';
151
+ }
152
+ this.filters.push(new Filter(name, _value, operand));
153
+ return this;
154
+ }
285
155
  }
286
156
 
287
- const DEFAULT_LIMIT = 20;
288
- const DEFAULT_OFFSET = 0;
289
- var APIOrder;
290
- (function (APIOrder) {
291
- APIOrder["asc"] = "a";
292
- APIOrder["desc"] = "d";
293
- })(APIOrder || (APIOrder = {}));
294
- class APIList extends APIEntity {
295
- create(data) {
296
- return this.post().data(data).send();
297
- }
298
- sort(name, order = APIOrder.asc) {
299
- return this.params({
300
- sort: `${name}_${order}`
301
- });
302
- }
303
- limit(limit = DEFAULT_LIMIT) {
304
- if (!Number.isNatural(limit)) {
305
- throw new Error(`Limit '${limit}' is invalid!`);
306
- }
307
- return this.params({
308
- limit
309
- });
310
- }
311
- getLimit() {
312
- const params = this.getParams();
313
- return params.limit == null ? DEFAULT_LIMIT : params.limit;
314
- }
315
- noLimit() {
316
- return this.limit(0);
317
- }
318
- offset(offset = DEFAULT_OFFSET) {
319
- if (!Number.isNatural(offset)) {
320
- throw new Error(`Offset '${offset}' is invalid!`);
321
- }
322
- return this.params({
323
- offset
324
- });
325
- }
326
- between(from, to) {
327
- if (!Number.isNatural(from)) {
328
- throw new Error(`From '${from}' is invalid!`);
329
- }
330
- if (!Number.isNatural(to)) {
331
- throw new Error(`To '${to}' is invalid!`);
332
- }
333
- return this.params({
334
- offset: from,
335
- limit: 1 + (to - from)
336
- });
337
- }
338
- only(idx) {
339
- if (!Number.isNatural(idx)) {
340
- throw new Error(`Index '${idx}' is invalid!`);
341
- }
342
- return this.params({
343
- offset: idx,
344
- limit: 1
345
- });
346
- }
347
- page(page = 1) {
348
- if (!Number.isNatural(page) || page == 0) {
349
- throw new Error(`Page '${page}' is invalid!`);
350
- }
351
- const limit = this.getLimit();
352
- const offset = (page - 1) * limit;
353
- return this.params({
354
- offset,
355
- limit
356
- });
357
- }
358
- search(query) {
359
- if (typeof query !== 'string') {
360
- throw new Error('Search query must be a string!');
361
- }
362
- return this.params({
363
- search: query
364
- });
365
- }
366
- filter(filter) {
367
- const isFilterBuilder = filter instanceof FilterBuilder;
368
- if (typeof filter !== 'string' && !isFilterBuilder) {
369
- throw new Error('Filter must be either string or instance of FilterBuilder');
370
- }
371
- if (isFilterBuilder) {
372
- filter = filter.toString();
373
- }
374
- return this.params({
375
- filter
376
- });
377
- }
378
- }
379
- APIList.prototype.all = APIList.prototype.noLimit;
380
- APIList.prototype.cut = APIList.prototype.between;
381
-
382
- class APIResource extends APIEntity {
383
- delete() {
384
- return this.method('DELETE');
385
- }
157
+ const ALLOWED_HTTP_METHODS = ['GET', 'POST', 'DELETE'];
158
+ var APIOrder;
159
+ (function (APIOrder) {
160
+ APIOrder["asc"] = "a";
161
+ APIOrder["desc"] = "d";
162
+ })(APIOrder || (APIOrder = {}));
163
+
164
+ class APIEntity {
165
+ constructor(parent) {
166
+ this.stack = [];
167
+ this.requestConfig = {};
168
+ this.ALLOWED_HTTP_METHODS = ALLOWED_HTTP_METHODS;
169
+ if (parent instanceof APIEntity) {
170
+ this.root = parent.root;
171
+ if (Array.isArray(parent.stack)) {
172
+ this.push(...parent.stack);
173
+ }
174
+ if (parent.requestConfig != null) {
175
+ this.setRequestConfig(parent.requestConfig);
176
+ }
177
+ }
178
+ else {
179
+ this.root = parent;
180
+ }
181
+ this.abortController = new nodeAbortController.AbortController();
182
+ }
183
+ abortRequest() {
184
+ this.abortController.abort();
185
+ }
186
+ push(...items) {
187
+ this.stack = this.stack.concat(items);
188
+ return this;
189
+ }
190
+ shift() {
191
+ this.stack.shift();
192
+ return this;
193
+ }
194
+ restack(...items) {
195
+ this.stack = items;
196
+ return this;
197
+ }
198
+ get first() {
199
+ return this.stack[0];
200
+ }
201
+ get last() {
202
+ return this.stack[this.stack.length - 1];
203
+ }
204
+ set last(val) {
205
+ this.stack[this.stack.length - 1] = val;
206
+ }
207
+ toUrl(absolute = false) {
208
+ let url = `/${this.stack.join('/')}`;
209
+ if (absolute) {
210
+ url = this.root.baseUrl + url;
211
+ }
212
+ return url;
213
+ }
214
+ setRequestConfig(requestConfig) {
215
+ Object.deepAssign(this.requestConfig, requestConfig);
216
+ return this;
217
+ }
218
+ removeRequestConfig(key) {
219
+ delete this.requestConfig[key];
220
+ return this;
221
+ }
222
+ headers(headers) {
223
+ const _headers = {};
224
+ for (const key in headers) {
225
+ const newKey = key.replace(/(?:^|-)([a-z])/g, (letter) => letter.toUpperCase());
226
+ _headers[newKey] = headers[key];
227
+ }
228
+ return this.setRequestConfig({
229
+ headers: _headers
230
+ });
231
+ }
232
+ method(name) {
233
+ const NAME = name.toLocaleUpperCase();
234
+ const isAllowed = this.ALLOWED_HTTP_METHODS.indexOf(NAME) > -1;
235
+ if (!isAllowed) {
236
+ throw new Error(`Method '${NAME}' is not allowed! You can use: ${this.ALLOWED_HTTP_METHODS.join(', ')}`);
237
+ }
238
+ return this.setRequestConfig({
239
+ method: NAME
240
+ });
241
+ }
242
+ get() {
243
+ return this.method('GET');
244
+ }
245
+ post() {
246
+ return this.method('POST');
247
+ }
248
+ params(params) {
249
+ this.setRequestConfig({ params });
250
+ return this;
251
+ }
252
+ getParams() {
253
+ return this.requestConfig.params == null ? {} : this.requestConfig.params;
254
+ }
255
+ removeParam(key) {
256
+ delete this.requestConfig.params[key];
257
+ return this;
258
+ }
259
+ data(data) {
260
+ this.setRequestConfig({ data });
261
+ return this;
262
+ }
263
+ jsonData(data) {
264
+ this.headers({
265
+ 'Content-Type': 'application/json'
266
+ }).data(data);
267
+ return this;
268
+ }
269
+ formData(data) {
270
+ this.headers({
271
+ 'Content-Type': 'multipart/form-data'
272
+ }).data(data);
273
+ return this;
274
+ }
275
+ send() {
276
+ const requestConfig = Object.deepAssign({}, this.requestConfig, {
277
+ url: `/${this.stack.join('/')}`,
278
+ signal: this.abortController.signal
279
+ });
280
+ if (requestConfig.headers == null) {
281
+ requestConfig.headers = {};
282
+ }
283
+ if (requestConfig.headers['Content-Type'] == null) {
284
+ requestConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
285
+ }
286
+ if (requestConfig.method === 'POST' &&
287
+ requestConfig.headers['Content-Type'].startsWith('application/x-www-form-urlencoded') &&
288
+ requestConfig.data != null) {
289
+ requestConfig.data = this.paramsSerializer(requestConfig.data);
290
+ }
291
+ if (requestConfig.params) {
292
+ requestConfig.paramsSerializer = this.paramsSerializer;
293
+ }
294
+ return this.root.axios.request(requestConfig);
295
+ }
296
+ paramsSerializer(params) {
297
+ return qs.stringify(params, {
298
+ arrayFormat: 'brackets'
299
+ });
300
+ }
386
301
  }
387
302
 
388
- class APIListCleanupConfigurations extends APIList {
389
- constructor(parent) {
390
- super(parent);
391
- this.push('cleanup-configurations');
392
- }
393
- specific() {
394
- return new APIResource(this).push('specific');
395
- }
303
+ const DEFAULT_LIMIT = 20;
304
+ const DEFAULT_OFFSET = 0;
305
+ class APIList extends APIEntity {
306
+ constructor() {
307
+ super(...arguments);
308
+ this.all = this.noLimit;
309
+ this.cut = this.between;
310
+ }
311
+ create(data) {
312
+ return this.post().data(data).send();
313
+ }
314
+ sort(name, order = APIOrder.asc) {
315
+ return this.params({
316
+ sort: `${name}_${order}`
317
+ });
318
+ }
319
+ limit(limit = DEFAULT_LIMIT) {
320
+ if (!Number.isNatural(limit)) {
321
+ throw new Error(`Limit '${limit}' is invalid!`);
322
+ }
323
+ return this.params({
324
+ limit
325
+ });
326
+ }
327
+ getLimit() {
328
+ const params = this.getParams();
329
+ return params.limit == null ? DEFAULT_LIMIT : params.limit;
330
+ }
331
+ noLimit() {
332
+ return this.limit(0);
333
+ }
334
+ offset(offset = DEFAULT_OFFSET) {
335
+ if (!Number.isNatural(offset)) {
336
+ throw new Error(`Offset '${offset}' is invalid!`);
337
+ }
338
+ return this.params({
339
+ offset
340
+ });
341
+ }
342
+ between(from, to) {
343
+ if (!Number.isNatural(from)) {
344
+ throw new Error(`From '${from}' is invalid!`);
345
+ }
346
+ if (!Number.isNatural(to)) {
347
+ throw new Error(`To '${to}' is invalid!`);
348
+ }
349
+ return this.params({
350
+ offset: from,
351
+ limit: 1 + (to - from)
352
+ });
353
+ }
354
+ only(idx) {
355
+ if (!Number.isNatural(idx)) {
356
+ throw new Error(`Index '${idx}' is invalid!`);
357
+ }
358
+ return this.params({
359
+ offset: idx,
360
+ limit: 1
361
+ });
362
+ }
363
+ page(page = 1) {
364
+ if (!Number.isNatural(page) || page == 0) {
365
+ throw new Error(`Page '${page}' is invalid!`);
366
+ }
367
+ const limit = this.getLimit();
368
+ const offset = (page - 1) * limit;
369
+ return this.params({
370
+ offset,
371
+ limit
372
+ });
373
+ }
374
+ search(query) {
375
+ if (typeof query !== 'string') {
376
+ throw new Error('Search query must be a string!');
377
+ }
378
+ return this.params({
379
+ search: query
380
+ });
381
+ }
382
+ filter(filter) {
383
+ const isFilterBuilder = filter instanceof FilterBuilder;
384
+ if (typeof filter !== 'string' && !isFilterBuilder) {
385
+ throw new Error('Filter must be either string or instance of FilterBuilder');
386
+ }
387
+ return this.params({
388
+ filter: filter.toString()
389
+ });
390
+ }
396
391
  }
397
392
 
398
- class APIResourceCleanupConfiguration extends APIResource {
399
- constructor(parent, id) {
400
- if (id == null) {
401
- throw new Error('Resource ID cannot be null!');
402
- }
403
- super(parent);
404
- this.push('cleanup-configurations', id);
405
- }
406
- devices() {
407
- return new APIList(this).push('devices');
408
- }
393
+ class APIResource extends APIEntity {
394
+ delete() {
395
+ return this.method('DELETE');
396
+ }
409
397
  }
410
398
 
411
- class APIListDevices extends APIList {
412
- constructor(parent) {
413
- super(parent);
414
- this.push('devices');
415
- }
416
- filters() {
417
- return new APIResource(this).push('filters');
418
- }
419
- cleanupConfigurations() {
420
- return new APIListCleanupConfigurations(this);
421
- }
422
- cleanupConfiguration(id) {
423
- return new APIResourceCleanupConfiguration(this, id);
424
- }
425
- desktopBrowserCapabilities() {
426
- return new APIResource(this).push('desktop-browser-capabilities');
427
- }
399
+ class APIListCleanupConfigurations extends APIList {
400
+ constructor(parent) {
401
+ super(parent);
402
+ this.push('cleanup-configurations');
403
+ }
404
+ specific() {
405
+ return new APIResource(this)
406
+ .push('specific');
407
+ }
428
408
  }
429
409
 
430
- class APIListUsers extends APIList {
431
- constructor(parent) {
432
- super(parent);
433
- this.push('users');
434
- }
435
- activate() {
436
- return new APIResource(this).push('activate').post();
437
- }
438
- recoveries() {
439
- return new APIResource(this).push('recoveries');
440
- }
441
- passwordRecovery() {
442
- return new APIResource(this).push('password-recovery');
443
- }
444
- resetApiKey() {
445
- return new APIResource(this).push('reset-api-key');
446
- }
447
- validateVatId() {
448
- return new APIResource(this).push('validateVatId');
449
- }
410
+ class APIResourceCleanupConfiguration extends APIResource {
411
+ constructor(parent, id) {
412
+ if (id == null) {
413
+ throw new Error('Resource ID cannot be null!');
414
+ }
415
+ super(parent);
416
+ this.push('cleanup-configurations', id);
417
+ }
418
+ devices() {
419
+ return new APIResource(this).push('devices');
420
+ }
450
421
  }
451
422
 
452
- class APIResourceBillingPeriod extends APIResource {
453
- constructor(parent, id) {
454
- if (id == null) {
455
- throw new Error('Resource ID cannot be null!');
456
- }
457
- super(parent);
458
- this.push('billing-periods', id);
459
- }
460
- receipt() {
461
- return new APIResource(this).push('receipt').setRequestConfig({
462
- responseType: 'arraybuffer'
463
- });
464
- }
423
+ class APIAdminListDevices extends APIList {
424
+ constructor(parent) {
425
+ super(parent);
426
+ this.push('admin', 'devices');
427
+ }
428
+ cleanupConfigurations() {
429
+ return new APIListCleanupConfigurations(this);
430
+ }
431
+ cleanupConfiguration(id) {
432
+ return new APIResourceCleanupConfiguration(this, id);
433
+ }
465
434
  }
466
435
 
467
- class APIResourceBuild extends APIResource {
468
- constructor(parent, id) {
469
- if (id == null) {
470
- throw new Error('Resource ID cannot be null!');
471
- }
472
- super(parent);
473
- this.push('builds', id);
474
- }
475
- abort() {
476
- return new APIResource(this).push('abort');
477
- }
478
- outputFiles() {
479
- return new APIList(this).push('output-file-set', 'files');
480
- }
436
+ class APIAdminListNotificationPlans extends APIList {
437
+ constructor(parent) {
438
+ super(parent);
439
+ this.push('admin', 'notification-plans');
440
+ }
441
+ channels() {
442
+ return new APIList(this).push('channels');
443
+ }
444
+ scopes() {
445
+ return new APIList(this).push('scopes');
446
+ }
481
447
  }
482
448
 
483
- class APIResourceJob extends APIResource {
484
- constructor(parent, id) {
485
- if (id == null) {
486
- throw new Error('Resource ID cannot be null!');
487
- }
488
- super(parent);
489
- this.push('jobs', id);
490
- }
491
- builds() {
492
- return new APIList(this).push('builds');
493
- }
494
- build(id) {
495
- return new APIResourceBuild(this, id);
496
- }
449
+ class APIAdminListRuns extends APIList {
450
+ constructor(parent) {
451
+ super(parent);
452
+ this.ALLOWED_HTTP_METHODS = ['GET'];
453
+ this.push('admin', 'runs');
454
+ }
455
+ config() {
456
+ const apiResource = new APIResource(this);
457
+ apiResource.restack('runs', 'config');
458
+ return apiResource;
459
+ }
497
460
  }
498
461
 
499
- class APIResourceDeviceGroup extends APIResource {
500
- constructor(parent, id) {
501
- if (id == null) {
502
- throw new Error('Resource ID cannot be null!');
503
- }
504
- super(parent);
505
- this.push('device-groups', id);
506
- }
507
- devices() {
508
- return new APIList(this).push('devices');
509
- }
510
- device(id) {
511
- if (id == null) {
512
- throw new Error('Resource ID cannot be null!');
513
- }
514
- return new APIResource(this).push('devices', id);
515
- }
516
- selectors() {
517
- return new APIList(this).push('selectors');
518
- }
519
- selector(id) {
520
- if (id == null) {
521
- throw new Error('Resource ID cannot be null!');
522
- }
523
- return new APIResource(this).push('selectors', id);
524
- }
525
- share() {
526
- return new APIResource(this).push('share');
527
- }
462
+ class APIAdminListServices extends APIList {
463
+ constructor(parent) {
464
+ super(parent);
465
+ this.push('admin', 'services');
466
+ }
467
+ active() {
468
+ const apiList = new APIList(this);
469
+ apiList.params({
470
+ notArchived: true
471
+ });
472
+ return apiList;
473
+ }
474
+ activated() {
475
+ const apiList = this.active();
476
+ apiList.params({
477
+ filter: 'activated_eq_true',
478
+ limit: 0,
479
+ sort: 'name_a'
480
+ });
481
+ return apiList;
482
+ }
483
+ inUse() {
484
+ const apiList = new APIList(this);
485
+ apiList.params({
486
+ inUse: true,
487
+ limit: 0,
488
+ sort: 'name_a'
489
+ });
490
+ return apiList;
491
+ }
492
+ byPrice() {
493
+ const apiList = new APIList(this);
494
+ apiList.params({
495
+ sort: 'centPrice_a'
496
+ });
497
+ return apiList;
498
+ }
528
499
  }
529
500
 
530
- function postDeviceRunIds(parent, name, ids) {
531
- const a = new APIResource(parent).push(name);
532
- if (ids != null) {
533
- a.params({
534
- deviceRunIds: ids
535
- });
536
- }
537
- return a.post();
501
+ function NonRequestable(constructor) {
502
+ return class extends constructor {
503
+ send() {
504
+ return Promise.reject();
505
+ }
506
+ };
538
507
  }
539
508
 
540
- class APIResourceRunCommon extends APIResource {
541
- constructor(parent, id) {
542
- if (id == null) {
543
- throw new Error('Resource ID cannot be null!');
544
- }
545
- super(parent);
546
- this.push('runs', id);
547
- }
548
- abort() {
549
- return new APIResource(this).push('abort').post();
550
- }
551
- dataAvailability() {
552
- return new APIList(this).push('data-availability');
553
- }
554
- deviceSessions() {
555
- return new APIList(this).push('device-sessions');
556
- }
557
- filesZip(ids) {
558
- return postDeviceRunIds(this, 'files.zip', ids);
559
- }
560
- logsZip(ids) {
561
- return postDeviceRunIds(this, 'logs.zip', ids);
562
- }
563
- performanceZip(ids) {
564
- return postDeviceRunIds(this, 'performance.zip', ids);
565
- }
566
- retry(ids) {
567
- return postDeviceRunIds(this, 'retry', ids).setRequestConfig({
568
- timeout: 0
569
- });
570
- }
571
- screenshotNames() {
572
- return new APIList(this).push('screenshot-names');
573
- }
574
- screenshots() {
575
- return new APIList(this).push('screenshots');
576
- }
577
- screenshotsZip(ids) {
578
- return postDeviceRunIds(this, 'screenshots.zip', ids);
579
- }
580
- steps() {
581
- return new APIList(this).push('steps');
582
- }
583
- tags() {
584
- return new APIList(this).push('tags');
585
- }
586
- tag(id) {
587
- if (id == null) {
588
- throw new Error('Resource ID cannot be null!');
589
- }
590
- return new APIResource(this).push('tags', id);
591
- }
592
- }
593
-
594
- class InputFileset extends APIResource {
595
- constructor(parent) {
596
- super(parent);
597
- this.push('input-file-set');
598
- }
599
- files() {
600
- return new APIList(this).push('files');
601
- }
602
- filesZip() {
603
- return new APIResource(this).push('files.zip');
604
- }
509
+ let APIAdminListStatistics = class APIAdminListStatistics extends APIList {
510
+ constructor(parent) {
511
+ super(parent);
512
+ this.push('admin', 'statistics');
513
+ }
514
+ deviceSessions() {
515
+ return new APIList(this).push('device-sessions');
516
+ }
517
+ frameworks() {
518
+ return new APIList(this).push('frameworks');
519
+ }
520
+ };
521
+ APIAdminListStatistics = __decorate([
522
+ NonRequestable
523
+ ], APIAdminListStatistics);
524
+
525
+ class APIAdminResourceAccountService extends APIResource {
526
+ constructor(parent, id) {
527
+ if (id == null) {
528
+ throw new Error('Resource ID cannot be null!');
529
+ }
530
+ super(parent);
531
+ this.push('admin', 'account-services', id);
532
+ }
533
+ activate() {
534
+ return new APIResource(this).push('activate').post();
535
+ }
536
+ deactivate() {
537
+ return new APIResource(this).push('deactivate').post();
538
+ }
605
539
  }
606
540
 
607
- const NON_MEDIA_FILES_FILTER = new FilterBuilder();
608
- NON_MEDIA_FILES_FILTER.eq('state', 'READY');
609
- NON_MEDIA_FILES_FILTER.notin('mimetype', [
610
- 'image/png', 'image/jpg', 'image/jpeg', 'image/webp', 'image/gif',
611
- 'video/mp4', 'video/avi', 'video/webm', 'video/ogg', 'video/mpeg'
612
- ]);
613
- class OutputFileset extends APIResource {
614
- constructor(parent) {
615
- super(parent);
616
- this.push('output-file-set');
617
- }
618
- files() {
619
- return new APIList(this).push('files');
620
- }
621
- file(id) {
622
- if (id == null) {
623
- throw new Error('Resource ID cannot be null!');
624
- }
625
- return new APIResource(this).push('files', id);
626
- }
627
- filesZip() {
628
- return new APIResource(this).push('files.zip');
629
- }
630
- screenshots() {
631
- return new APIList(this).push('screenshots');
632
- }
633
- screenshot(id) {
634
- if (id == null) {
635
- throw new Error('Resource ID cannot be null!');
636
- }
637
- return new APIResource(this).push('screenshots', id);
638
- }
639
- screenshotFile(id) {
640
- this.screenshot(id).push('file');
641
- }
642
- videos() {
643
- return this.files().params({
644
- filter: 's_state_eq_READY',
645
- tag: ['video']
646
- });
647
- }
648
- nonMediaFiles() {
649
- return this.files().filter(NON_MEDIA_FILES_FILTER);
650
- }
541
+ class APIAdminResourceCluster extends APIResource {
542
+ constructor(parent, id) {
543
+ if (id == null) {
544
+ throw new Error('Resource ID cannot be null!');
545
+ }
546
+ super(parent);
547
+ this.push('clusters', id);
548
+ }
549
+ devices() {
550
+ return new APIList(this).push('devices');
551
+ }
651
552
  }
652
553
 
653
- class APIResourceDeviceSessionCommon extends APIResource {
654
- constructor(parent, id) {
655
- if (id == null) {
656
- throw new Error('Resource ID cannot be null!');
657
- }
658
- super(parent);
659
- this.push('device-sessions', id);
660
- }
661
- commands() {
662
- return new APIList(this).push('commands');
663
- }
664
- input() {
665
- return new InputFileset(this);
666
- }
667
- output() {
668
- return new OutputFileset(this);
669
- }
670
- screenshots() {
671
- return new APIList(this).push('screenshots');
672
- }
673
- screenshot(id) {
674
- if (id == null) {
675
- throw new Error('Resource ID cannot be null!');
676
- }
677
- return new APIResource(this).push('screenshots', id);
678
- }
679
- steps() {
680
- return new APIList(this).push('steps');
681
- }
682
- step(id) {
683
- if (id == null) {
684
- throw new Error('Resource ID cannot be null!');
685
- }
686
- return new APIResource(this).push('steps', id);
687
- }
688
- currentStep() {
689
- return this.step('current');
690
- }
691
- testCaseRuns() {
692
- return new APIList(this).push('test-case-runs');
693
- }
554
+ class APIAdminResourceDevice extends APIResource {
555
+ constructor(parent, id) {
556
+ if (id == null) {
557
+ throw new Error('Resource ID cannot be null!');
558
+ }
559
+ super(parent);
560
+ this.push('admin', 'devices', id);
561
+ }
562
+ blink() {
563
+ return new APIResource(this).push('blink').post();
564
+ }
565
+ cleanupConfiguration() {
566
+ return new APIResource(this).push('cleanup-configuration');
567
+ }
568
+ labels() {
569
+ return new APIList(this).push('labels');
570
+ }
571
+ label(id) {
572
+ return new APIResource(this).push('labels', id);
573
+ }
574
+ queue() {
575
+ return new APIList(this).push('queue');
576
+ }
694
577
  }
695
578
 
696
- class APIResourceDeviceSession extends APIResourceDeviceSessionCommon {
697
- abort() {
698
- return new APIResource(this).push('abort').post();
699
- }
700
- retry() {
701
- return new APIResource(this).push('retry').post();
702
- }
579
+ class APIAdminResourceDeviceModel extends APIResource {
580
+ constructor(parent, id) {
581
+ if (id == null) {
582
+ throw new Error('Resource ID cannot be null!');
583
+ }
584
+ super(parent);
585
+ this.push('admin', 'device-models', id);
586
+ }
587
+ browsers() {
588
+ return new APIList(this).push('browsers');
589
+ }
703
590
  }
704
591
 
705
- class APIResourceRun extends APIResourceRunCommon {
706
- deviceSession(id) {
707
- return new APIResourceDeviceSession(this, id);
708
- }
592
+ let InputFileset = class InputFileset extends APIResource {
593
+ constructor(parent) {
594
+ super(parent);
595
+ this.push('input-file-set');
596
+ }
597
+ files() {
598
+ return new APIList(this).push('files');
599
+ }
600
+ filesZip() {
601
+ return new APIResource(this).push('files.zip');
602
+ }
603
+ };
604
+ InputFileset = __decorate([
605
+ NonRequestable
606
+ ], InputFileset);
607
+
608
+ const IMAGE_FILES_FILTER = new FilterBuilder();
609
+ IMAGE_FILES_FILTER.eq('state', 'READY');
610
+ IMAGE_FILES_FILTER.in('mimetype', [
611
+ 'image/png', 'image/jpg', 'image/jpeg', 'image/webp', 'image/gif'
612
+ ]);
613
+ IMAGE_FILES_FILTER.notlike('name', 'action-%%');
614
+
615
+ const NON_MEDIA_FILES_FILTER = new FilterBuilder();
616
+ NON_MEDIA_FILES_FILTER.eq('state', 'READY');
617
+ NON_MEDIA_FILES_FILTER.notin('mimetype', [
618
+ 'image/png', 'image/jpg', 'image/jpeg', 'image/webp', 'image/gif',
619
+ 'video/mp4', 'video/avi', 'video/webm', 'video/ogg', 'video/mpeg'
620
+ ]);
621
+
622
+ let OutputFileset = class OutputFileset extends APIResource {
623
+ constructor(parent) {
624
+ super(parent);
625
+ this.push('output-file-set');
626
+ }
627
+ files() {
628
+ return new APIList(this).push('files');
629
+ }
630
+ file(id) {
631
+ return new APIResource(this).push('files', id);
632
+ }
633
+ filesZip() {
634
+ return new APIResource(this).push('files.zip');
635
+ }
636
+ screenshots() {
637
+ return new APIList(this).push('screenshots');
638
+ }
639
+ screenshot(id) {
640
+ return new APIResource(this).push('screenshots', id);
641
+ }
642
+ screenshotFile(id) {
643
+ return this.screenshot(id).push('file');
644
+ }
645
+ videos() {
646
+ return this.files().params({
647
+ filter: 's_state_eq_READY',
648
+ tag: ['video']
649
+ });
650
+ }
651
+ nonMediaFiles() {
652
+ return this.files().filter(NON_MEDIA_FILES_FILTER);
653
+ }
654
+ performance() {
655
+ return this.files().params({
656
+ tag: ['performance']
657
+ });
658
+ }
659
+ images() {
660
+ return this.files().filter(IMAGE_FILES_FILTER);
661
+ }
662
+ };
663
+ OutputFileset = __decorate([
664
+ NonRequestable
665
+ ], OutputFileset);
666
+
667
+ class APIResourceDeviceSessionCommon extends APIResource {
668
+ constructor(parent, id) {
669
+ if (id == null) {
670
+ throw new Error('Resource ID cannot be null!');
671
+ }
672
+ super(parent);
673
+ this.push('device-sessions', id);
674
+ }
675
+ commands() {
676
+ return new APIList(this).push('commands');
677
+ }
678
+ input() {
679
+ return new InputFileset(this);
680
+ }
681
+ output() {
682
+ return new OutputFileset(this);
683
+ }
684
+ screenshots() {
685
+ return new APIList(this).push('screenshots');
686
+ }
687
+ screenshot(id) {
688
+ if (id == null) {
689
+ throw new Error('Resource ID cannot be null!');
690
+ }
691
+ return new APIResource(this).push('screenshots', id);
692
+ }
693
+ steps() {
694
+ return new APIList(this).push('steps');
695
+ }
696
+ step(id) {
697
+ if (id == null) {
698
+ throw new Error('Resource ID cannot be null!');
699
+ }
700
+ return new APIResource(this).push('steps', id);
701
+ }
702
+ currentStep() {
703
+ return this.step('current');
704
+ }
705
+ testCaseRuns() {
706
+ return new APIList(this).push('test-case-runs');
707
+ }
708
+ connections() {
709
+ return new APIList(this).push('connections');
710
+ }
711
+ logs() {
712
+ return new APIResource(this).push('logs').setRequestConfig({
713
+ responseType: 'text'
714
+ });
715
+ }
709
716
  }
710
717
 
711
- class APIResourceProject extends APIResource {
712
- constructor(parent, id) {
713
- if (id == null) {
714
- throw new Error('Resource ID cannot be null!');
715
- }
716
- super(parent);
717
- this.push('projects', id);
718
- }
719
- runs() {
720
- return new APIList(this).push('runs');
721
- }
722
- run(id) {
723
- return new APIResourceRun(this, id);
724
- }
725
- runsExtended() {
726
- return new APIList(this).push('runs-extended');
727
- }
728
- runExtended(id) {
729
- if (id == null) {
730
- throw new Error('Resource ID cannot be null!');
731
- }
732
- return new APIResource(this).push('runs-extended', id);
733
- }
734
- files() {
735
- return new APIList(this).push('files');
736
- }
737
- filesZip() {
738
- return new APIResource(this).push('files.zip');
739
- }
740
- sharings() {
741
- return new APIList(this).push('sharings');
742
- }
743
- sharing(id) {
744
- if (id == null) {
745
- throw new Error('Resource ID cannot be null!');
746
- }
747
- return new APIResource(this).push('sharings', id);
748
- }
718
+ function postAdminDeviceSessionChangeBillable(parent, billable) {
719
+ const apiResource = new APIResource(parent);
720
+ const deviceSessionId = apiResource.last;
721
+ return apiResource.restack('admin', 'device-sessions', deviceSessionId, 'changebillable').params({
722
+ billable
723
+ }).post();
749
724
  }
750
725
 
751
- class APIResourceFile extends APIResource {
752
- constructor(parent, id) {
753
- if (id == null) {
754
- throw new Error('Resource ID cannot be null!');
755
- }
756
- super(parent);
757
- this.push('files', id);
758
- }
759
- file() {
760
- return new APIResource(this).push('file');
761
- }
762
- icon() {
763
- return new APIResource(this).push('icon');
764
- }
765
- tags() {
766
- return new APIList(this).push('tags');
767
- }
726
+ class APIAdminResourceDeviceSessionStandalone extends APIResourceDeviceSessionCommon {
727
+ changeBillable(billable) {
728
+ return postAdminDeviceSessionChangeBillable(this, billable);
729
+ }
768
730
  }
769
731
 
770
- class APIResourceNotification extends APIResource {
771
- constructor(parent, id) {
772
- if (id == null) {
773
- throw new Error('Resource ID cannot be null!');
774
- }
775
- super(parent);
776
- this.push('notifications', id);
777
- }
778
- test() {
779
- return new APIResource(this).push('test');
780
- }
732
+ class APIAdminResourceDeviceTime extends APIList {
733
+ constructor(parent) {
734
+ super(parent);
735
+ this.push('admin', 'device-time');
736
+ }
737
+ countSessionReport() {
738
+ return new APIList(this).push('count-session-report');
739
+ }
740
+ stepTimeReport() {
741
+ return new APIList(this).push('step-time-report');
742
+ }
781
743
  }
782
744
 
783
- class APIResourceAccessGroup extends APIResource {
784
- constructor(parent, id) {
785
- if (id == null) {
786
- throw new Error('Resource ID cannot be null!');
787
- }
788
- super(parent);
789
- this.push('access-groups', id);
790
- }
791
- users() {
792
- return new APIList(this).push('users');
793
- }
794
- user(id) {
795
- if (id == null) {
796
- throw new Error('Resource ID cannot be null!');
797
- }
798
- return new APIResource(this).push('users', id);
799
- }
800
- resources() {
801
- return new APIList(this).push('resources');
802
- }
803
- resource(id) {
804
- if (id == null) {
805
- throw new Error('Resource ID cannot be null!');
806
- }
807
- return new APIResource(this).push('resources', id);
808
- }
745
+ class APIAdminResourceFramework extends APIResource {
746
+ constructor(parent, id) {
747
+ if (id == null) {
748
+ throw new Error('Resource ID cannot be null!');
749
+ }
750
+ super(parent);
751
+ this.push('admin', 'frameworks', id);
752
+ }
753
+ config() {
754
+ return new APIResource(this).push('config');
755
+ }
756
+ requiredRoles() {
757
+ return new APIList(this).push('required-roles');
758
+ }
809
759
  }
810
760
 
811
- class APIResourceAdditionalUser extends APIResource {
812
- constructor(parent, id) {
813
- if (id == null) {
814
- throw new Error('Resource ID cannot be null!');
815
- }
816
- super(parent);
817
- this.push('additional-users', id);
818
- }
819
- resendActivation() {
820
- return new APIResource(this).push('resend-activation');
821
- }
761
+ class APIAdminResourceLicense extends APIResource {
762
+ constructor(parent, id) {
763
+ if (id == null) {
764
+ throw new Error('Resource ID cannot be null!');
765
+ }
766
+ super(parent);
767
+ this.push('admin', 'licenses', id);
768
+ }
769
+ activate() {
770
+ return new APIResource(this).push('activate');
771
+ }
772
+ deactivate() {
773
+ return new APIResource(this).push('deactivate');
774
+ }
775
+ resend() {
776
+ return new APIResource(this).push('resend');
777
+ }
778
+ download() {
779
+ return new APIResource(this).push('download');
780
+ }
822
781
  }
823
782
 
824
- class APIUserResourceAccount extends APIResource {
825
- constructor(parent) {
826
- super(parent);
827
- this.push('account');
828
- }
829
- additionalUsers() {
830
- return new APIList(this).push('additional-users');
831
- }
832
- additionalUser(id) {
833
- return new APIResourceAdditionalUser(this, id);
834
- }
835
- serviceBillingPeriod(id) {
836
- if (id == null) {
837
- throw new Error('Resource ID cannot be null!');
838
- }
839
- const a = new APIResource(this);
840
- a.last += '-services';
841
- a.push(id, 'billing-period');
842
- return a;
843
- }
783
+ class APIAdminResourceNotificationPlan extends APIResource {
784
+ constructor(parent, id) {
785
+ if (id == null) {
786
+ throw new Error('Resource ID cannot be null!');
787
+ }
788
+ super(parent);
789
+ this.push('admin', 'notification-plans', id);
790
+ }
791
+ check() {
792
+ return new APIList(this).push('check');
793
+ }
794
+ test() {
795
+ return new APIResource(this).push('test');
796
+ }
797
+ execute() {
798
+ return new APIResource(this).push('execute');
799
+ }
844
800
  }
845
801
 
846
- class APIListDeviceTime extends APIList {
847
- constructor(parent) {
848
- super(parent);
849
- this.push('device-time');
850
- }
851
- reserved() {
852
- return new APIList(this).push('reserved');
853
- }
854
- used() {
855
- return new APIList(this).push('used');
856
- }
802
+ function postDeviceRunIds(parent, name, ids) {
803
+ const a = new APIResource(parent).push(name);
804
+ if (ids != null) {
805
+ a.params({
806
+ deviceRunIds: ids
807
+ });
808
+ }
809
+ return a.post();
857
810
  }
858
811
 
859
- class APIListFiles extends APIList {
860
- constructor(parent) {
861
- super(parent);
862
- this.push('files');
863
- }
864
- upload(obj) {
865
- let form;
866
- if (global.isNodeJs) {
867
- const fs = require('fs');
868
- const FormData = require('form-data');
869
- form = new FormData();
870
- form.append('file', fs.createReadStream(obj.dir + '/' + obj.filename), {
871
- filename: obj.filename
872
- });
873
- }
874
- else {
875
- throw new Error('Not supported yet!');
876
- }
877
- return this.post().headers(form.getHeaders()).data(form);
878
- }
812
+ class APIAdminResourceRunStandalone extends APIResource {
813
+ constructor(parent, id) {
814
+ if (id == null) {
815
+ throw new Error('Resource ID cannot be null!');
816
+ }
817
+ super(parent);
818
+ this.push('admin', 'runs', id);
819
+ }
820
+ abort() {
821
+ return new APIResource(this).push('abort').post();
822
+ }
823
+ changeBillable(billable) {
824
+ return new APIResource(this).push('changebillable').post().params({
825
+ billable
826
+ });
827
+ }
828
+ changePriority(priority) {
829
+ return new APIResource(this).push('changepriority').post().params({
830
+ priority
831
+ });
832
+ }
833
+ retry(ids) {
834
+ return postDeviceRunIds(this, 'retry', ids).setRequestConfig({
835
+ timeout: 0
836
+ });
837
+ }
879
838
  }
880
839
 
881
- class APIListPurchased extends APIList {
882
- constructor(parent) {
883
- super(parent);
884
- this.push('purchased');
885
- }
840
+ class APIAdminResourceService extends APIResource {
841
+ constructor(parent, id) {
842
+ if (id == null) {
843
+ throw new Error('Resource ID cannot be null!');
844
+ }
845
+ super(parent);
846
+ this.push('admin', 'services', id);
847
+ }
848
+ activate() {
849
+ return new APIResource(this).push('activate').post();
850
+ }
886
851
  }
887
852
 
888
- class APIListServices extends APIList {
889
- constructor(parent) {
890
- super(parent);
891
- this.push('services');
892
- }
893
- purchased() {
894
- return new APIListPurchased(this);
895
- }
896
- available() {
897
- return new APIList(this).push('available');
898
- }
899
- active() {
900
- const a = new APIList(this);
901
- if (this.first === 'me') {
902
- a.push('active');
903
- }
904
- else {
905
- a.params({
906
- notArchived: true
907
- });
908
- }
909
- return a;
910
- }
853
+ let APIAdminResourceUserAccount = class APIAdminResourceUserAccount extends APIResource {
854
+ constructor(parent) {
855
+ super(parent);
856
+ this.push('account');
857
+ }
858
+ roles() {
859
+ return new APIList(this).push('roles');
860
+ }
861
+ role(id) {
862
+ if (id == null) {
863
+ throw new Error('Resource ID cannot be null!');
864
+ }
865
+ return new APIResource(this).push('roles', id);
866
+ }
867
+ services() {
868
+ const a = new APIList(this);
869
+ a.last += '-services';
870
+ return a;
871
+ }
872
+ update() {
873
+ const a = new APIResource(this);
874
+ a.last = 'update-account';
875
+ return a.post();
876
+ }
877
+ };
878
+ APIAdminResourceUserAccount = __decorate([
879
+ NonRequestable
880
+ ], APIAdminResourceUserAccount);
881
+
882
+ class APIResourceDeviceSessionStandalone extends APIResource {
883
+ constructor(parent, id) {
884
+ if (id == null) {
885
+ throw new Error('Resource ID cannot be null!');
886
+ }
887
+ super(parent);
888
+ this.push('device-sessions', id);
889
+ }
890
+ connections() {
891
+ return new APIList(this).push('connections');
892
+ }
893
+ connection(id) {
894
+ if (id == null) {
895
+ throw new Error('Resource ID cannot be null!');
896
+ }
897
+ return new APIResource(this).push('connections', id);
898
+ }
899
+ input() {
900
+ return new InputFileset(this);
901
+ }
902
+ output() {
903
+ return new OutputFileset(this);
904
+ }
905
+ release() {
906
+ return new APIResource(this).push('release').post();
907
+ }
911
908
  }
912
909
 
913
- class APIListRuns extends APIList {
914
- constructor(parent) {
915
- super(parent);
916
- this.push('runs');
917
- }
918
- config() {
919
- return new APIResource(this).push('config');
920
- }
910
+ let APIAdminResourceUser = class APIAdminResourceUser extends APIResource {
911
+ constructor(parent, id) {
912
+ if (id == null) {
913
+ throw new Error('Resource ID cannot be null!');
914
+ }
915
+ super(parent);
916
+ this.push('admin', 'users', id);
917
+ }
918
+ disable() {
919
+ return new APIResource(this).push('disable');
920
+ }
921
+ enable() {
922
+ return new APIResource(this).push('enable');
923
+ }
924
+ licenses() {
925
+ return new APIList(this).push('licenses');
926
+ }
927
+ resendActivation() {
928
+ return new APIResource(this).push('resend-activation').post();
929
+ }
930
+ account() {
931
+ return new APIAdminResourceUserAccount(this);
932
+ }
933
+ deviceSession(id) {
934
+ return new APIResourceDeviceSessionStandalone(this, id);
935
+ }
936
+ };
937
+ APIAdminResourceUser = __decorate([
938
+ NonRequestable
939
+ ], APIAdminResourceUser);
940
+
941
+ class APIResourceAccessGroup extends APIResource {
942
+ constructor(parent, id) {
943
+ if (id == null) {
944
+ throw new Error('Resource ID cannot be null!');
945
+ }
946
+ super(parent);
947
+ this.push('access-groups', id);
948
+ }
949
+ users() {
950
+ return new APIList(this).push('users');
951
+ }
952
+ user(id) {
953
+ if (id == null) {
954
+ throw new Error('Resource ID cannot be null!');
955
+ }
956
+ return new APIResource(this).push('users', id);
957
+ }
958
+ resources() {
959
+ return new APIList(this).push('resources');
960
+ }
961
+ resource(id) {
962
+ if (id == null) {
963
+ throw new Error('Resource ID cannot be null!');
964
+ }
965
+ return new APIResource(this).push('resources', id);
966
+ }
921
967
  }
922
968
 
923
- class APIListNotifications extends APIList {
924
- constructor(parent) {
925
- super(parent);
926
- this.push('notifications');
927
- }
928
- scopes() {
929
- return new APIList(this).push('scopes');
930
- }
931
- channels() {
932
- return new APIList(this).push('channels');
933
- }
969
+ class APIResourceDeviceGroup extends APIResource {
970
+ constructor(parent, id) {
971
+ if (id == null) {
972
+ throw new Error('Resource ID cannot be null!');
973
+ }
974
+ super(parent);
975
+ this.push('device-groups', id);
976
+ }
977
+ devices() {
978
+ return new APIList(this).push('devices');
979
+ }
980
+ device(id) {
981
+ if (id == null) {
982
+ throw new Error('Resource ID cannot be null!');
983
+ }
984
+ return new APIResource(this).push('devices', id);
985
+ }
986
+ selectors() {
987
+ return new APIList(this).push('selectors');
988
+ }
989
+ selector(id) {
990
+ if (id == null) {
991
+ throw new Error('Resource ID cannot be null!');
992
+ }
993
+ return new APIResource(this).push('selectors', id);
994
+ }
995
+ share() {
996
+ return new APIResource(this).push('share');
997
+ }
934
998
  }
935
999
 
936
- class APIListSmartbearTunnels extends APIList {
937
- constructor(parent) {
938
- super(parent);
939
- this.push('tunnels');
940
- }
941
- active(active) {
942
- return this.params({ active: active });
943
- }
1000
+ class APIResourceFile extends APIResource {
1001
+ constructor(parent, id) {
1002
+ if (id == null) {
1003
+ throw new Error('Resource ID cannot be null!');
1004
+ }
1005
+ super(parent);
1006
+ this.push('files', id);
1007
+ }
1008
+ file() {
1009
+ return new APIResource(this).push('file');
1010
+ }
1011
+ icon() {
1012
+ return new APIResource(this).push('icon');
1013
+ }
1014
+ tags() {
1015
+ return new APIList(this).push('tags');
1016
+ }
1017
+ share() {
1018
+ return new APIList(this).push('share');
1019
+ }
944
1020
  }
945
1021
 
946
- class APIResourceDeviceSessionStandalone extends APIResource {
947
- constructor(parent, id) {
948
- if (id == null) {
949
- throw new Error('Resource ID cannot be null!');
950
- }
951
- super(parent);
952
- this.push('device-sessions', id);
953
- }
954
- connections() {
955
- return new APIList(this).push('connections');
956
- }
957
- connection(id) {
958
- if (id == null) {
959
- throw new Error('Resource ID cannot be null!');
960
- }
961
- return new APIResource(this).push('connections', id);
962
- }
963
- input() {
964
- return new InputFileset(this);
965
- }
966
- output() {
967
- return new OutputFileset(this);
968
- }
969
- release() {
970
- return new APIResource(this).push('release').post();
971
- }
1022
+ class APIResourceDeviceSession extends APIResourceDeviceSessionCommon {
1023
+ abort() {
1024
+ return new APIResource(this).push('abort').post();
1025
+ }
1026
+ retry() {
1027
+ return new APIResource(this).push('retry').post();
1028
+ }
972
1029
  }
973
1030
 
974
- class APIResourceUser extends APIResource {
975
- constructor(parent, id) {
976
- if (id == null) {
977
- throw new Error('Resource ID cannot be null!');
978
- }
979
- super(parent);
980
- if (id === 'me') {
981
- this.push('me');
982
- }
983
- else if (typeof id === 'number') {
984
- this.push('users', id);
985
- }
986
- else {
987
- throw new TypeError('id is not a number');
988
- }
989
- }
990
- account() {
991
- return new APIUserResourceAccount(this);
992
- }
993
- deviceTime() {
994
- return new APIListDeviceTime(this);
995
- }
996
- deviceTimeSummary() {
997
- return new APIList(this).push('device-time-summary');
998
- }
999
- services() {
1000
- return new APIListServices(this);
1001
- }
1002
- service(id) {
1003
- if (id == null) {
1004
- throw new Error('Resource ID cannot be null!');
1005
- }
1006
- return new APIResource(this).push('services', id);
1007
- }
1008
- billingPeriods() {
1009
- return new APIList(this).push('billing-periods');
1010
- }
1011
- billingPeriod(id) {
1012
- return new APIResourceBillingPeriod(this, id);
1013
- }
1014
- jobs() {
1015
- return new APIList(this).push('jobs');
1016
- }
1017
- job(id) {
1018
- return new APIResourceJob(this, id);
1019
- }
1020
- deviceGroups() {
1021
- return new APIList(this).push('device-groups');
1022
- }
1023
- deviceGroup(id) {
1024
- return new APIResourceDeviceGroup(this, id);
1025
- }
1026
- deviceSessions() {
1027
- return new APIList(this).push('device-sessions');
1028
- }
1029
- deviceSession(id) {
1030
- return new APIResourceDeviceSessionStandalone(this, id);
1031
- }
1032
- projects() {
1033
- return new APIList(this).push('projects');
1034
- }
1035
- project(id) {
1036
- return new APIResourceProject(this, id);
1037
- }
1038
- files() {
1039
- return new APIListFiles(this);
1040
- }
1041
- file(id) {
1042
- return new APIResourceFile(this, id);
1043
- }
1044
- runs() {
1045
- return new APIListRuns(this);
1046
- }
1047
- availableBuildExecutors() {
1048
- return new APIList(this).push('available-build-executors');
1049
- }
1050
- availableFrameworks() {
1051
- return new APIList(this).push('available-frameworks');
1052
- }
1053
- resetApiKey() {
1054
- return new APIResource(this).push('reset-api-key');
1055
- }
1056
- restore() {
1057
- return new APIResource(this).push('restore');
1058
- }
1059
- feedback() {
1060
- return new APIResource(this).push('feedback');
1061
- }
1062
- notifications() {
1063
- return new APIListNotifications(this);
1064
- }
1065
- notification(id) {
1066
- return new APIResourceNotification(this, id);
1067
- }
1068
- receipts() {
1069
- return new APIList(this).push('receipts');
1070
- }
1071
- preferences() {
1072
- return new APIResource(this).push('preferences');
1073
- }
1074
- uiPreferences() {
1075
- return new APIResource(this).push('ui-preferences');
1076
- }
1077
- deviceUsage() {
1078
- return new APIList(this).push('device-usage');
1079
- }
1080
- statistics() {
1081
- return new APIList(this).push('statistics');
1082
- }
1083
- deviceStatistics() {
1084
- return new APIList(this).push('device-statistics');
1085
- }
1086
- accessGroups() {
1087
- return new APIList(this).push('access-groups');
1088
- }
1089
- accessGroup(id) {
1090
- return new APIResourceAccessGroup(this, id);
1091
- }
1092
- smartbearTunnel(id) {
1093
- return new APIResource(this).push('tunnels', id);
1094
- }
1095
- smartbearTunnels() {
1096
- return new APIListSmartbearTunnels(this);
1097
- }
1031
+ class APIResourceRunCommon extends APIResource {
1032
+ constructor(parent, id) {
1033
+ if (id == null) {
1034
+ throw new Error('Resource ID cannot be null!');
1035
+ }
1036
+ super(parent);
1037
+ this.push('runs', id);
1038
+ }
1039
+ abort() {
1040
+ return new APIResource(this).push('abort').post();
1041
+ }
1042
+ dataAvailability() {
1043
+ return new APIResource(this).push('data-availability');
1044
+ }
1045
+ deviceSessions() {
1046
+ return new APIList(this).push('device-sessions');
1047
+ }
1048
+ filesZip(ids) {
1049
+ return postDeviceRunIds(this, 'files.zip', ids);
1050
+ }
1051
+ logsZip(ids) {
1052
+ return postDeviceRunIds(this, 'logs.zip', ids);
1053
+ }
1054
+ performanceZip(ids) {
1055
+ return postDeviceRunIds(this, 'performance.zip', ids);
1056
+ }
1057
+ retry(ids) {
1058
+ return postDeviceRunIds(this, 'retry', ids).setRequestConfig({
1059
+ timeout: 0
1060
+ });
1061
+ }
1062
+ screenshotNames() {
1063
+ return new APIList(this).push('screenshot-names');
1064
+ }
1065
+ screenshots() {
1066
+ return new APIList(this).push('screenshots');
1067
+ }
1068
+ screenshotsZip(ids) {
1069
+ return postDeviceRunIds(this, 'screenshots.zip', ids);
1070
+ }
1071
+ steps() {
1072
+ return new APIList(this).push('steps');
1073
+ }
1074
+ tags() {
1075
+ return new APIList(this).push('tags');
1076
+ }
1077
+ tag(id) {
1078
+ if (id == null) {
1079
+ throw new Error('Resource ID cannot be null!');
1080
+ }
1081
+ return new APIResource(this).push('tags', id);
1082
+ }
1098
1083
  }
1099
1084
 
1100
- class APIResourceDevice extends APIResource {
1101
- constructor(parent, id) {
1102
- if (id == null) {
1103
- throw new Error('Resource ID cannot be null!');
1104
- }
1105
- super(parent);
1106
- this.push('devices', id);
1107
- }
1108
- properties() {
1109
- return new APIList(this).push('properties');
1110
- }
1085
+ class APIResourceRun extends APIResourceRunCommon {
1086
+ deviceSession(id) {
1087
+ return new APIResourceDeviceSession(this, id);
1088
+ }
1111
1089
  }
1112
1090
 
1113
- class APIResourceUserSession extends APIResource {
1114
- constructor(parent) {
1115
- super(parent);
1116
- this.push('user-sessions');
1117
- }
1118
- login(data) {
1119
- return new APIResource(this).push('login').post().data(data);
1120
- }
1121
- logout() {
1122
- return new APIResource(this).push('logout').post();
1123
- }
1124
- sso(name) {
1125
- return new APIResource(this).push(name + '-login');
1126
- }
1127
- portalLogin() {
1128
- return new APIResource(this).push('portal-login').post();
1129
- }
1091
+ class APIResourceProject extends APIResource {
1092
+ constructor(parent, id) {
1093
+ if (id == null) {
1094
+ throw new Error('Resource ID cannot be null!');
1095
+ }
1096
+ super(parent);
1097
+ this.push('projects', id);
1098
+ }
1099
+ runs() {
1100
+ return new APIList(this).push('runs');
1101
+ }
1102
+ run(id) {
1103
+ return new APIResourceRun(this, id);
1104
+ }
1130
1105
  }
1131
1106
 
1132
- class APIAdminListRuns extends APIList {
1133
- constructor(parent) {
1134
- super(parent);
1135
- this.push('admin', 'runs');
1136
- }
1137
- config() {
1138
- const a = new APIResource(this);
1139
- a.stack = ['runs', 'config'];
1140
- return a;
1141
- }
1107
+ let APIAdminResource = class APIAdminResource extends APIResource {
1108
+ constructor(parent) {
1109
+ super(parent);
1110
+ }
1111
+ accessGroups() {
1112
+ return new APIList(this).push('access-groups');
1113
+ }
1114
+ accessGroup(id) {
1115
+ return new APIResourceAccessGroup(this, id);
1116
+ }
1117
+ accounts() {
1118
+ return new APIList(this).push('admin', 'accounts');
1119
+ }
1120
+ account(id) {
1121
+ if (id == null) {
1122
+ throw new Error('Resource ID cannot be null!');
1123
+ }
1124
+ return new APIResource(this).push('admin', 'accounts', id);
1125
+ }
1126
+ accountServices() {
1127
+ return new APIList(this).push('admin', 'account-services');
1128
+ }
1129
+ accountService(id) {
1130
+ return new APIAdminResourceAccountService(this, id);
1131
+ }
1132
+ activities() {
1133
+ return new APIList(this).push('admin', 'activities');
1134
+ }
1135
+ billingPeriods() {
1136
+ return new APIList(this).push('admin', 'billing-periods');
1137
+ }
1138
+ billingPeriod(id) {
1139
+ if (id == null) {
1140
+ throw new Error('Resource ID cannot be null!');
1141
+ }
1142
+ return new APIResource(this).push('admin', 'billing-periods', id);
1143
+ }
1144
+ browsers() {
1145
+ return new APIList(this).push('admin', 'browsers');
1146
+ }
1147
+ browser(id) {
1148
+ if (id == null) {
1149
+ throw new Error('Resource ID cannot be null!');
1150
+ }
1151
+ return new APIResource(this).push('admin', 'browsers', id);
1152
+ }
1153
+ clusters() {
1154
+ return new APIList(this).push('clusters');
1155
+ }
1156
+ cluster(id) {
1157
+ return new APIAdminResourceCluster(this, id);
1158
+ }
1159
+ countryVatRates() {
1160
+ return new APIList(this).push('admin', 'country-vat-rates');
1161
+ }
1162
+ countryVatRate(id) {
1163
+ if (id == null) {
1164
+ throw new Error('Resource ID cannot be null!');
1165
+ }
1166
+ return new APIResource(this).push('admin', 'country-vat-rates', id);
1167
+ }
1168
+ devices() {
1169
+ return new APIAdminListDevices(this);
1170
+ }
1171
+ device(id) {
1172
+ return new APIAdminResourceDevice(this, id);
1173
+ }
1174
+ devicesForModel(id) {
1175
+ if (id == null) {
1176
+ throw new Error('Resource ID cannot be null!');
1177
+ }
1178
+ const apiList = this.devices();
1179
+ apiList.params({
1180
+ filter: 'deviceModelId_eq_' + id
1181
+ });
1182
+ return apiList;
1183
+ }
1184
+ deviceStatuses() {
1185
+ return new APIList(this).push('admin', 'device', 'statuses');
1186
+ }
1187
+ deviceModels() {
1188
+ return new APIList(this).push('admin', 'device-models');
1189
+ }
1190
+ deviceModel(id) {
1191
+ return new APIAdminResourceDeviceModel(this, id);
1192
+ }
1193
+ deviceProblems() {
1194
+ return new APIList(this).push('admin', 'device-problems');
1195
+ }
1196
+ deviceModelCriterias() {
1197
+ return new APIList(this).push('admin', 'device-model-criteria');
1198
+ }
1199
+ deviceModelCriteria(id) {
1200
+ if (id == null) {
1201
+ throw new Error('Resource ID cannot be null!');
1202
+ }
1203
+ return new APIResource(this).push('admin', 'device-model-criteria', id);
1204
+ }
1205
+ deviceSessions() {
1206
+ return new APIList(this).push('admin', 'device-sessions');
1207
+ }
1208
+ deviceSession(id) {
1209
+ return new APIAdminResourceDeviceSessionStandalone(this, id);
1210
+ }
1211
+ deviceTime() {
1212
+ return new APIAdminResourceDeviceTime(this);
1213
+ }
1214
+ deviceTimeSummary() {
1215
+ return new APIList(this).push('admin', 'device-time-summary');
1216
+ }
1217
+ deviceTypes() {
1218
+ return new APIList(this).push('admin', 'device-types');
1219
+ }
1220
+ deviceType(id) {
1221
+ return new APIResource(this).push('admin', 'device-types', id);
1222
+ }
1223
+ deviceGroups() {
1224
+ return new APIList(this).push('device-groups');
1225
+ }
1226
+ deviceGroup(id) {
1227
+ return new APIResourceDeviceGroup(this, id);
1228
+ }
1229
+ emails() {
1230
+ return new APIList(this).push('admin', 'emails');
1231
+ }
1232
+ resendEmail(id) {
1233
+ if (id == null) {
1234
+ throw new Error('Resource ID cannot be null!');
1235
+ }
1236
+ return new APIResource(this).push('admin', 'emails', id, 'resend').post();
1237
+ }
1238
+ errors() {
1239
+ return new APIList(this).push('admin', 'errors');
1240
+ }
1241
+ files() {
1242
+ return new APIList(this).push('files');
1243
+ }
1244
+ file(id) {
1245
+ return new APIResourceFile(this, id);
1246
+ }
1247
+ frameworks() {
1248
+ return new APIList(this).push('admin', 'frameworks');
1249
+ }
1250
+ framework(id) {
1251
+ return new APIAdminResourceFramework(this, id);
1252
+ }
1253
+ frameworkAvailableLabels() {
1254
+ const apiList = this.frameworks();
1255
+ apiList.push('available-labels');
1256
+ return apiList;
1257
+ }
1258
+ interactiveQueue() {
1259
+ return new APIList(this).push('admin', 'interactive-queue');
1260
+ }
1261
+ licenses() {
1262
+ return new APIList(this).push('admin', 'licenses');
1263
+ }
1264
+ license(id) {
1265
+ return new APIAdminResourceLicense(this, id);
1266
+ }
1267
+ maintenance() {
1268
+ return new APIResource(this).push('admin', 'maintenance');
1269
+ }
1270
+ notificationPlans() {
1271
+ return new APIAdminListNotificationPlans(this);
1272
+ }
1273
+ notificationPlan(id) {
1274
+ return new APIAdminResourceNotificationPlan(this, id);
1275
+ }
1276
+ overview() {
1277
+ return new APIResource(this).push('admin', 'overview');
1278
+ }
1279
+ pools() {
1280
+ return new APIList(this).push('admin', 'pools');
1281
+ }
1282
+ pool(id) {
1283
+ return new APIResource(this).push('admin', 'pools', id);
1284
+ }
1285
+ projects() {
1286
+ return new APIList(this).push('projects');
1287
+ }
1288
+ project(id) {
1289
+ return new APIResourceProject(this, id);
1290
+ }
1291
+ roles() {
1292
+ return new APIList(this).push('admin', 'roles');
1293
+ }
1294
+ runs() {
1295
+ return new APIAdminListRuns(this);
1296
+ }
1297
+ run(id) {
1298
+ return new APIAdminResourceRunStandalone(this, id);
1299
+ }
1300
+ samples() {
1301
+ return new APIList(this).push('admin', 'samples');
1302
+ }
1303
+ sample(id) {
1304
+ if (id == null) {
1305
+ throw new Error('Resource ID cannot be null!');
1306
+ }
1307
+ return new APIResource(this).push('admin', 'samples', id);
1308
+ }
1309
+ services() {
1310
+ return new APIAdminListServices(this);
1311
+ }
1312
+ service(id) {
1313
+ return new APIAdminResourceService(this, id);
1314
+ }
1315
+ settings() {
1316
+ return new APIResource(this).push('admin', 'settings');
1317
+ }
1318
+ statistics() {
1319
+ return new APIAdminListStatistics(this);
1320
+ }
1321
+ users() {
1322
+ return new APIList(this).push('users');
1323
+ }
1324
+ createUser() {
1325
+ return new APIList(this).push('admin', 'users').post();
1326
+ }
1327
+ user(id) {
1328
+ return new APIAdminResourceUser(this, id);
1329
+ }
1330
+ };
1331
+ APIAdminResource = __decorate([
1332
+ NonRequestable
1333
+ ], APIAdminResource);
1334
+
1335
+ class APIListDevices extends APIList {
1336
+ constructor(parent) {
1337
+ super(parent);
1338
+ this.push('devices');
1339
+ }
1340
+ filters() {
1341
+ return new APIResource(this).push('filters');
1342
+ }
1343
+ desktopBrowserCapabilities() {
1344
+ return new APIResource(this).push('desktop-browser-capabilities');
1345
+ }
1142
1346
  }
1143
1347
 
1144
- class APIAdminResourceCluster extends APIResource {
1145
- constructor(parent, id) {
1146
- if (id == null) {
1147
- throw new Error('Resource ID cannot be null!');
1148
- }
1149
- super(parent);
1150
- this.push('clusters', id);
1151
- }
1152
- devices() {
1153
- return new APIList(this).push('devices');
1154
- }
1348
+ class APIListProperties extends APIList {
1349
+ constructor(parent) {
1350
+ super(parent);
1351
+ this.push('properties');
1352
+ }
1353
+ appBan(id) {
1354
+ if (id == null) {
1355
+ throw new Error('Resource ID cannot be null!');
1356
+ }
1357
+ return new APIList(this).push('app-bans').params({
1358
+ testRunId: id
1359
+ });
1360
+ }
1361
+ maintenance() {
1362
+ return new APIList(this).params({
1363
+ filter: 'name_eq_CLOUD_HEADER_ANNOUNCEMENT',
1364
+ limit: 1,
1365
+ sort: 'updateTime_d'
1366
+ });
1367
+ }
1155
1368
  }
1156
1369
 
1157
- class APIAdminResourceDeviceTime extends APIResource {
1158
- constructor(parent) {
1159
- super(parent);
1160
- this.push('admin', 'device-time');
1161
- }
1162
- countSessionReport() {
1163
- return new APIList(this).push('count-session-report');
1164
- }
1165
- stepTimeReport() {
1166
- return new APIList(this).push('step-time-report');
1167
- }
1370
+ class APIListServices extends APIList {
1371
+ constructor(parent) {
1372
+ super(parent);
1373
+ this.ALLOWED_HTTP_METHODS = ['POST'];
1374
+ this.push('services');
1375
+ }
1376
+ available() {
1377
+ return new APIList(this).push('available');
1378
+ }
1379
+ active() {
1380
+ const apiList = new APIList(this);
1381
+ if (this.first === 'me') {
1382
+ apiList.push('active');
1383
+ }
1384
+ else {
1385
+ apiList.params({
1386
+ notArchived: true
1387
+ });
1388
+ }
1389
+ return apiList;
1390
+ }
1391
+ byPrice() {
1392
+ return new APIList(this).sort('centPrice');
1393
+ }
1394
+ availableByPrice() {
1395
+ return new APIList(this).push('available').sort('centPrice');
1396
+ }
1168
1397
  }
1169
1398
 
1170
- class APIAdminResourceRunStandalone extends APIResource {
1171
- constructor(parent, id) {
1172
- if (id == null) {
1173
- throw new Error('Resource ID cannot be null!');
1174
- }
1175
- super(parent);
1176
- this.push('admin', 'runs', id);
1177
- }
1178
- abort() {
1179
- return new APIResource(this).push('abort').post();
1180
- }
1181
- changeBillable(billable) {
1182
- return new APIResource(this).push('changebillable').post().params({
1183
- billable
1184
- });
1185
- }
1186
- changePriority(priority) {
1187
- return new APIResource(this).push('changepriority').post().params({
1188
- priority
1189
- });
1190
- }
1191
- retry(ids) {
1192
- return postDeviceRunIds(this, 'retry', ids).setRequestConfig({
1193
- timeout: 0
1194
- });
1195
- }
1196
- deviceSessions() {
1197
- return new APIList(this).shift().push('device-sessions');
1198
- }
1199
- deviceSession(id) {
1200
- return new APIResourceDeviceSessionCommon(this, id).shift();
1201
- }
1399
+ class APIListUsers extends APIList {
1400
+ constructor(parent) {
1401
+ super(parent);
1402
+ this.ALLOWED_HTTP_METHODS = ['POST'];
1403
+ this.push('users');
1404
+ }
1405
+ activate() {
1406
+ return new APIResource(this).push('activate').post();
1407
+ }
1408
+ recoveries() {
1409
+ return new APIResource(this).push('recoveries');
1410
+ }
1411
+ passwordRecovery() {
1412
+ return new APIResource(this).push('password-recovery');
1413
+ }
1414
+ validateVatId() {
1415
+ return new APIResource(this).push('validateVatId');
1416
+ }
1202
1417
  }
1203
1418
 
1204
- class APIAdminResourceDevice extends APIResource {
1205
- constructor(parent, id) {
1206
- if (id == null) {
1207
- throw new Error('Resource ID cannot be null!');
1208
- }
1209
- super(parent);
1210
- this.push('admin', 'devices', id);
1211
- }
1212
- queue() {
1213
- return new APIList(this).push('queue');
1214
- }
1215
- cleanupConfiguration() {
1216
- return new APIResource(this).push('cleanup-configuration');
1217
- }
1218
- labels() {
1219
- return new APIList(this).push('labels');
1220
- }
1221
- label(id) {
1222
- return new APIResource(this).push('labels', id);
1223
- }
1224
- blink() {
1225
- return new APIResource(this).push('blink').post();
1226
- }
1419
+ class APIResourceAccount extends APIResource {
1420
+ constructor(parent, id) {
1421
+ if (id == null) {
1422
+ throw new Error('Resource ID cannot be null!');
1423
+ }
1424
+ super(parent);
1425
+ this.push('accounts', id);
1426
+ }
1427
+ concurrencyStatus() {
1428
+ return new APIResource(this).push('concurrency-status');
1429
+ }
1430
+ preferences() {
1431
+ return new APIResource(this).push('preferences');
1432
+ }
1227
1433
  }
1228
1434
 
1229
- class APIAdminResourceAccountService extends APIResource {
1230
- constructor(parent, id) {
1231
- if (id == null) {
1232
- throw new Error('Resource ID cannot be null!');
1233
- }
1234
- super(parent);
1235
- this.push('admin', 'account-services', id);
1236
- }
1237
- activate() {
1238
- return new APIResource(this).push('activate').post();
1239
- }
1240
- deactivate() {
1241
- return new APIResource(this).push('deactivate').post();
1242
- }
1435
+ class APIResourceBroker extends APIResource {
1436
+ constructor(parent) {
1437
+ super(parent);
1438
+ this.push('broker');
1439
+ }
1440
+ hubs() {
1441
+ return new APIList(this).push('hubs');
1442
+ }
1243
1443
  }
1244
1444
 
1245
- class APIAdminResourceUserAccount extends APIResource {
1246
- constructor(parent) {
1247
- super(parent);
1248
- this.push('account');
1249
- }
1250
- roles() {
1251
- return new APIList(this).push('roles');
1252
- }
1253
- role(id) {
1254
- if (id == null) {
1255
- throw new Error('Resource ID cannot be null!');
1256
- }
1257
- return new APIResource(this).push('roles', id);
1258
- }
1259
- services() {
1260
- const a = new APIList(this);
1261
- a.last += '-services';
1262
- return a;
1263
- }
1264
- update() {
1265
- const a = new APIResource(this);
1266
- a.last = 'update-account';
1267
- return a.post();
1268
- }
1445
+ class APIResourceDevice extends APIResource {
1446
+ constructor(parent, id) {
1447
+ if (id == null) {
1448
+ throw new Error('Resource ID cannot be null!');
1449
+ }
1450
+ super(parent);
1451
+ this.push('devices', id);
1452
+ }
1453
+ properties() {
1454
+ return new APIList(this).push('properties');
1455
+ }
1456
+ browsers() {
1457
+ return new APIList(this).push('browsers');
1458
+ }
1269
1459
  }
1270
1460
 
1271
- class APIAdminResourceUser extends APIResource {
1272
- constructor(parent, id) {
1273
- if (id == null) {
1274
- throw new Error('Resource ID cannot be null!');
1275
- }
1276
- super(parent);
1277
- this.push('admin', 'users', id);
1278
- }
1279
- disable() {
1280
- return new APIResource(this).push('disable');
1281
- }
1282
- enable() {
1283
- return new APIResource(this).push('enable');
1284
- }
1285
- licenses() {
1286
- return new APIList(this).push('licenses');
1287
- }
1288
- resendActivation() {
1289
- return new APIResource(this).push('resend-activation').post();
1290
- }
1291
- account() {
1292
- return new APIAdminResourceUserAccount(this);
1293
- }
1461
+ class APIResourceLabelGroup extends APIResource {
1462
+ constructor(parent, id) {
1463
+ if (id == null) {
1464
+ throw new Error('Resource ID cannot be null!');
1465
+ }
1466
+ super(parent);
1467
+ this.push('label-groups', id);
1468
+ }
1469
+ labels() {
1470
+ return new APIList(this).push('labels');
1471
+ }
1472
+ label(id) {
1473
+ return new APIResource(this).push('labels', id);
1474
+ }
1294
1475
  }
1295
1476
 
1296
- function postAdminDeviceSessionChangeBillable(parent, billable) {
1297
- const a = new APIResource(parent);
1298
- const deviceSessionId = a.last;
1299
- return a.restack('admin', 'device-sessions', deviceSessionId, 'changebillable').params({
1300
- billable
1301
- }).post();
1477
+ class APIListDeviceTime extends APIList {
1478
+ constructor(parent) {
1479
+ super(parent);
1480
+ this.push('device-time');
1481
+ }
1482
+ reserved() {
1483
+ return new APIEntity(this).push('reserved');
1484
+ }
1485
+ used() {
1486
+ return new APIEntity(this).push('used');
1487
+ }
1302
1488
  }
1303
1489
 
1304
- class APIAdminResourceDeviceSessionStandalone extends APIResourceDeviceSessionCommon {
1305
- changeBillable(billable) {
1306
- return postAdminDeviceSessionChangeBillable(this, billable);
1307
- }
1308
- connections() {
1309
- return new APIList(this).push('connections');
1310
- }
1311
- connection(id) {
1312
- if (id == null) {
1313
- throw new Error('Resource ID cannot be null!');
1314
- }
1315
- return new APIResource(this).push('connections', id);
1316
- }
1317
- release() {
1318
- return new APIResource(this).push('release').post();
1319
- }
1490
+ class APIListFiles extends APIList {
1491
+ constructor(parent) {
1492
+ super(parent);
1493
+ this.push('files');
1494
+ }
1495
+ upload(obj) {
1496
+ if (global.isNodeJs) {
1497
+ return this.nodeUpload(obj);
1498
+ }
1499
+ else {
1500
+ throw new Error('Not supported yet!');
1501
+ }
1502
+ }
1503
+ nodeUpload(file) {
1504
+ const fs = require('fs');
1505
+ const FormData = require('form-data');
1506
+ const form = new FormData();
1507
+ form.append('file', fs.createReadStream(file.dir + '/' + file.filename), {
1508
+ filename: file.filename
1509
+ });
1510
+ return this.post().headers(form.getHeaders()).data(form);
1511
+ }
1320
1512
  }
1321
1513
 
1322
- class APIAdminListDevices extends APIList {
1323
- constructor(parent) {
1324
- super(parent);
1325
- this.push('admin', 'devices');
1326
- }
1327
- filters() {
1328
- return new APIResource(this).push('filters');
1329
- }
1330
- cleanupConfigurations() {
1331
- return new APIListCleanupConfigurations(this);
1332
- }
1333
- cleanupConfiguration(id) {
1334
- return new APIResourceCleanupConfiguration(this, id);
1335
- }
1336
- desktopBrowserCapabilities() {
1337
- return new APIResource(this).push('desktop-browser-capabilities');
1338
- }
1514
+ class APIResourceChannel extends APIResource {
1515
+ constructor(parent, type) {
1516
+ if (type == null) {
1517
+ throw new Error('Resource ID cannot be null!');
1518
+ }
1519
+ super(parent);
1520
+ this.push('channels', type);
1521
+ }
1522
+ scopes() {
1523
+ return new APIList(this).push('scopes');
1524
+ }
1339
1525
  }
1340
1526
 
1341
- class APIAdminResourceFramework extends APIResource {
1342
- constructor(parent, id) {
1343
- if (id == null) {
1344
- throw new Error('Resource ID cannot be null!');
1345
- }
1346
- super(parent);
1347
- this.push('admin', 'frameworks', id);
1348
- }
1349
- config() {
1350
- return new APIResource(this).push('config');
1351
- }
1352
- requiredRoles() {
1353
- return new APIList(this).push('required-roles');
1354
- }
1527
+ class APIListNotifications extends APIList {
1528
+ constructor(parent) {
1529
+ super(parent);
1530
+ this.push('notifications');
1531
+ }
1532
+ scopes() {
1533
+ return new APIList(this).push('scopes');
1534
+ }
1535
+ channels() {
1536
+ return new APIList(this).push('channels');
1537
+ }
1538
+ channel(type) {
1539
+ return new APIResourceChannel(this, type);
1540
+ }
1355
1541
  }
1356
1542
 
1357
- class APIAdminResourceLicense extends APIResource {
1358
- constructor(parent, id) {
1359
- if (id == null) {
1360
- throw new Error('Resource ID cannot be null!');
1361
- }
1362
- super(parent);
1363
- this.push('admin', 'licenses', id);
1364
- }
1365
- activate() {
1366
- return new APIResource(this).push('activate');
1367
- }
1368
- deactivate() {
1369
- return new APIResource(this).push('deactivate');
1370
- }
1371
- resend() {
1372
- return new APIResource(this).push('resend');
1373
- }
1374
- download() {
1375
- return new APIResource(this).push('download');
1376
- }
1543
+ class APIListRuns extends APIList {
1544
+ constructor(parent) {
1545
+ super(parent);
1546
+ this.push('runs');
1547
+ }
1548
+ config() {
1549
+ return new APIResource(this).push('config');
1550
+ }
1377
1551
  }
1378
1552
 
1379
- class APIAdminListNotificationPlans extends APIList {
1380
- constructor(parent) {
1381
- super(parent);
1382
- this.push('admin', 'notification-plans');
1383
- }
1384
- channels() {
1385
- return new APIList(this).push('channels');
1386
- }
1387
- scopes() {
1388
- return new APIList(this).push('scopes');
1389
- }
1553
+ class APIListSmartbearTunnels extends APIList {
1554
+ constructor(parent) {
1555
+ super(parent);
1556
+ this.ALLOWED_HTTP_METHODS = ['GET'];
1557
+ this.push('tunnels');
1558
+ }
1559
+ active(active) {
1560
+ return this.params({ active: active });
1561
+ }
1390
1562
  }
1391
1563
 
1392
- class APIAdminResourceNotificationPlan extends APIResource {
1393
- constructor(parent, id) {
1394
- if (id == null) {
1395
- throw new Error('Resource ID cannot be null!');
1396
- }
1397
- super(parent);
1398
- this.push('admin', 'notification-plans', id);
1399
- }
1400
- check() {
1401
- return new APIList(this).push('check');
1402
- }
1403
- test() {
1404
- return new APIResource(this).push('test');
1405
- }
1406
- execute() {
1407
- return new APIResource(this).push('execute');
1408
- }
1564
+ class APIResourceBillingPeriod extends APIResource {
1565
+ constructor(parent, id) {
1566
+ if (id == null) {
1567
+ throw new Error('Resource ID cannot be null!');
1568
+ }
1569
+ super(parent);
1570
+ this.push('billing-periods', id);
1571
+ }
1572
+ receipt() {
1573
+ return new APIResource(this).push('receipt').setRequestConfig({
1574
+ responseType: 'arraybuffer'
1575
+ });
1576
+ }
1409
1577
  }
1410
1578
 
1411
- class APIAdminResourceService extends APIResource {
1412
- constructor(parent, id) {
1413
- if (id == null) {
1414
- throw new Error('Resource ID cannot be null!');
1415
- }
1416
- super(parent);
1417
- this.push('admin', 'services', id);
1418
- }
1419
- activate() {
1420
- return new APIResource(this).push('activate').post();
1421
- }
1422
- deactivate() {
1423
- return new APIResource(this).push('deactivate').post();
1424
- }
1425
- roles() {
1426
- return new APIList(this).push('roles');
1427
- }
1579
+ class APIResourceNotification extends APIResource {
1580
+ constructor(parent, id) {
1581
+ if (id == null) {
1582
+ throw new Error('Resource ID cannot be null!');
1583
+ }
1584
+ super(parent);
1585
+ this.push('notifications', id);
1586
+ }
1587
+ test() {
1588
+ return new APIResource(this).push('test');
1589
+ }
1428
1590
  }
1429
1591
 
1430
- class APIAdminListServices extends APIList {
1431
- constructor(parent) {
1432
- super(parent);
1433
- this.push('admin', 'services');
1434
- }
1435
- purchased() {
1436
- return new APIListPurchased(this);
1437
- }
1438
- available() {
1439
- return new APIList(this).push('available');
1440
- }
1441
- active() {
1442
- const a = new APIList(this);
1443
- if (this.first === 'me') {
1444
- a.push('active');
1445
- }
1446
- else {
1447
- a.params({
1448
- notArchived: true
1449
- });
1450
- }
1451
- return a;
1452
- }
1453
- activated() {
1454
- const a = this.active();
1455
- a.params({
1456
- filter: 'activated_eq_true',
1457
- limit: 0,
1458
- sort: 'name_a'
1459
- });
1460
- return a;
1461
- }
1462
- inUse() {
1463
- const a = new APIList(this);
1464
- a.params({
1465
- inUse: true,
1466
- limit: 0,
1467
- sort: 'name_a'
1468
- });
1469
- return a;
1470
- }
1471
- byPrice() {
1472
- const a = new APIList(this);
1473
- a.params({
1474
- sort: 'centPrice_a'
1475
- });
1476
- return a;
1477
- }
1592
+ class APIResourceAdditionalUser extends APIResource {
1593
+ constructor(parent, id) {
1594
+ if (id == null) {
1595
+ throw new Error('Resource ID cannot be null!');
1596
+ }
1597
+ super(parent);
1598
+ this.push('additional-users', id);
1599
+ }
1600
+ resendActivation() {
1601
+ return new APIResource(this).push('resend-activation');
1602
+ }
1478
1603
  }
1479
1604
 
1480
- class APIAdminListStatistics extends APIList {
1481
- constructor(parent) {
1482
- super(parent);
1483
- this.push('admin', 'statistics');
1484
- }
1485
- deviceSessions() {
1486
- return new APIList(this).push('device-sessions');
1487
- }
1488
- frameworks() {
1489
- return new APIList(this).push('frameworks');
1490
- }
1605
+ class APIUserResourceAccount extends APIResource {
1606
+ constructor(parent) {
1607
+ super(parent);
1608
+ this.push('account');
1609
+ }
1610
+ additionalUsers() {
1611
+ return new APIList(this).push('additional-users');
1612
+ }
1613
+ additionalUser(id) {
1614
+ return new APIResourceAdditionalUser(this, id);
1615
+ }
1616
+ serviceBillingPeriod(id) {
1617
+ if (id == null) {
1618
+ throw new Error('Resource ID cannot be null!');
1619
+ }
1620
+ const a = new APIResource(this);
1621
+ a.last += '-services';
1622
+ a.push(id, 'billing-period');
1623
+ return a;
1624
+ }
1491
1625
  }
1492
1626
 
1493
- class APIAdminResourceDeviceModel extends APIResource {
1494
- constructor(parent, id) {
1495
- if (id == null) {
1496
- throw new Error('Resource ID cannot be null!');
1497
- }
1498
- super(parent);
1499
- this.push('device-models', id);
1500
- }
1501
- browsers() {
1502
- return new APIList(this).push('browsers');
1503
- }
1627
+ class APIResourceUser extends APIResource {
1628
+ constructor(parent, id) {
1629
+ if (id == null) {
1630
+ throw new Error('Resource ID cannot be null!');
1631
+ }
1632
+ super(parent);
1633
+ if (id === 'me') {
1634
+ this.push('me');
1635
+ }
1636
+ else if (typeof id === 'number') {
1637
+ this.push('users', id);
1638
+ }
1639
+ else {
1640
+ throw new TypeError('id is not a number');
1641
+ }
1642
+ }
1643
+ account() {
1644
+ return new APIUserResourceAccount(this);
1645
+ }
1646
+ deviceTime() {
1647
+ return new APIListDeviceTime(this);
1648
+ }
1649
+ deviceTimeSummary() {
1650
+ return new APIList(this).push('device-time-summary');
1651
+ }
1652
+ services() {
1653
+ return new APIListServices(this);
1654
+ }
1655
+ service(id) {
1656
+ if (id == null) {
1657
+ throw new Error('Resource ID cannot be null!');
1658
+ }
1659
+ return new APIResource(this).push('services', id);
1660
+ }
1661
+ billingPeriods() {
1662
+ return new APIList(this).push('billing-periods');
1663
+ }
1664
+ billingPeriod(id) {
1665
+ return new APIResourceBillingPeriod(this, id);
1666
+ }
1667
+ deviceGroups() {
1668
+ return new APIList(this).push('device-groups');
1669
+ }
1670
+ deviceGroup(id) {
1671
+ return new APIResourceDeviceGroup(this, id);
1672
+ }
1673
+ deviceSessions() {
1674
+ return new APIList(this).push('device-sessions');
1675
+ }
1676
+ deviceSession(id) {
1677
+ return new APIResourceDeviceSessionStandalone(this, id);
1678
+ }
1679
+ projects() {
1680
+ return new APIList(this).push('projects');
1681
+ }
1682
+ project(id) {
1683
+ return new APIResourceProject(this, id);
1684
+ }
1685
+ files() {
1686
+ return new APIListFiles(this);
1687
+ }
1688
+ file(id) {
1689
+ return new APIResourceFile(this, id);
1690
+ }
1691
+ runs() {
1692
+ return new APIListRuns(this);
1693
+ }
1694
+ availableFrameworks() {
1695
+ return new APIList(this).push('available-frameworks');
1696
+ }
1697
+ resetApiKey() {
1698
+ return new APIResource(this).push('reset-api-key');
1699
+ }
1700
+ restore() {
1701
+ return new APIResource(this).push('restore');
1702
+ }
1703
+ feedback() {
1704
+ return new APIResource(this).push('feedback');
1705
+ }
1706
+ notifications() {
1707
+ return new APIListNotifications(this);
1708
+ }
1709
+ notification(id) {
1710
+ return new APIResourceNotification(this, id);
1711
+ }
1712
+ preferences() {
1713
+ return new APIResource(this).push('preferences');
1714
+ }
1715
+ uiPreferences() {
1716
+ return new APIResource(this).push('ui-preferences');
1717
+ }
1718
+ deviceUsage() {
1719
+ return new APIList(this).push('device-usage');
1720
+ }
1721
+ statistics() {
1722
+ return new APIResource(this).push('statistics');
1723
+ }
1724
+ deviceStatistics() {
1725
+ return new APIList(this).push('device-statistics');
1726
+ }
1727
+ accessGroups() {
1728
+ return new APIList(this).push('access-groups');
1729
+ }
1730
+ accessGroup(id) {
1731
+ return new APIResourceAccessGroup(this, id);
1732
+ }
1733
+ smartbearTunnel(id) {
1734
+ return new APIResource(this).push('tunnels', id);
1735
+ }
1736
+ smartbearTunnels() {
1737
+ return new APIListSmartbearTunnels(this);
1738
+ }
1739
+ deleteAccount() {
1740
+ return new APIResource(this).push('delete');
1741
+ }
1504
1742
  }
1505
1743
 
1506
- class APIAdminResource extends APIResource {
1507
- constructor(parent) {
1508
- super(parent);
1509
- }
1510
- accessGroups() {
1511
- return new APIList(this).push('access-groups');
1512
- }
1513
- accessGroup(id) {
1514
- return new APIResourceAccessGroup(this, id);
1515
- }
1516
- accounts() {
1517
- return new APIList(this).push('admin', 'accounts');
1518
- }
1519
- account(id) {
1520
- if (id == null) {
1521
- throw new Error('Resource ID cannot be null!');
1522
- }
1523
- return new APIResource(this).push('admin', 'accounts', id);
1524
- }
1525
- accountServices() {
1526
- return new APIList(this).push('admin', 'account-services');
1527
- }
1528
- accountService(id) {
1529
- return new APIAdminResourceAccountService(this, id);
1530
- }
1531
- activities() {
1532
- return new APIList(this).push('admin', 'activities');
1533
- }
1534
- billingPeriods() {
1535
- return new APIList(this).push('admin', 'billing-periods');
1536
- }
1537
- billingPeriod(id) {
1538
- if (id == null) {
1539
- throw new Error('Resource ID cannot be null!');
1540
- }
1541
- return new APIResource(this).push('admin', 'billing-periods', id);
1542
- }
1543
- browsers() {
1544
- return new APIList(this).push('admin', 'browsers');
1545
- }
1546
- browser(id) {
1547
- if (id == null) {
1548
- throw new Error('Resource ID cannot be null!');
1549
- }
1550
- return new APIResource(this).push('admin', 'browsers', id);
1551
- }
1552
- clusters() {
1553
- return new APIList(this).push('clusters');
1554
- }
1555
- cluster(id) {
1556
- return new APIAdminResourceCluster(this, id);
1557
- }
1558
- countryVatRates() {
1559
- return new APIList(this).push('admin', 'country-vat-rates');
1560
- }
1561
- countryVatRate(id) {
1562
- if (id == null) {
1563
- throw new Error('Resource ID cannot be null!');
1564
- }
1565
- return new APIResource(this).push('admin', 'country-vat-rates', id);
1566
- }
1567
- devices() {
1568
- return new APIAdminListDevices(this);
1569
- }
1570
- device(id) {
1571
- return new APIAdminResourceDevice(this, id);
1572
- }
1573
- devicesForModel(id) {
1574
- if (id == null) {
1575
- throw new Error('Resource ID cannot be null!');
1576
- }
1577
- const a = this.devices();
1578
- a.params({
1579
- filter: 'deviceModelId_eq_' + id
1580
- });
1581
- return a;
1582
- }
1583
- deviceStatuses() {
1584
- return new APIList(this).push('admin', 'device', 'statuses');
1585
- }
1586
- deviceModels() {
1587
- return new APIList(this).push('admin', 'device-models');
1588
- }
1589
- deviceModel(id) {
1590
- return new APIAdminResourceDeviceModel(this, id);
1591
- }
1592
- deviceProblems() {
1593
- return new APIList(this).push('admin', 'device-problems');
1594
- }
1595
- deviceModelCriterias() {
1596
- return new APIList(this).push('admin', 'device-model-criteria');
1597
- }
1598
- deviceModelCriteria(id) {
1599
- if (id == null) {
1600
- throw new Error('Resource ID cannot be null!');
1601
- }
1602
- return new APIResource(this).push('admin', 'device-model-criteria', id);
1603
- }
1604
- deviceSessions() {
1605
- return new APIList(this).push('admin', 'device-sessions');
1606
- }
1607
- deviceSession(id) {
1608
- return new APIAdminResourceDeviceSessionStandalone(this, id);
1609
- }
1610
- deviceTime() {
1611
- return new APIAdminResourceDeviceTime(this);
1612
- }
1613
- deviceTimeSummary() {
1614
- return new APIList(this).push('admin', 'device-time-summary');
1615
- }
1616
- deviceTypes() {
1617
- return new APIList(this).push('admin', 'device-types');
1618
- }
1619
- deviceType(id) {
1620
- return new APIResource(this).push('admin', 'device-types', id);
1621
- }
1622
- deviceGroups() {
1623
- return new APIList(this).push('device-groups');
1624
- }
1625
- deviceGroup(id) {
1626
- return new APIResourceDeviceGroup(this, id);
1627
- }
1628
- emails() {
1629
- return new APIList(this).push('admin', 'emails');
1630
- }
1631
- resendEmail(id) {
1632
- if (id == null) {
1633
- throw new Error('Resource ID cannot be null!');
1634
- }
1635
- return new APIResource(this).push('admin', 'emails', id, 'resend').post();
1636
- }
1637
- errors() {
1638
- return new APIList(this).push('admin', 'errors');
1639
- }
1640
- files() {
1641
- return new APIList(this).push('files');
1642
- }
1643
- file(id) {
1644
- return new APIResourceFile(this, id);
1645
- }
1646
- frameworks() {
1647
- return new APIList(this).push('admin', 'frameworks');
1648
- }
1649
- framework(id) {
1650
- return new APIAdminResourceFramework(this, id);
1651
- }
1652
- frameworkAvailableLabels() {
1653
- const a = this.frameworks();
1654
- a.push('available-labels');
1655
- return a;
1656
- }
1657
- interactiveQueue() {
1658
- return new APIList(this).push('admin', 'interactive-queue');
1659
- }
1660
- licenses() {
1661
- return new APIList(this).push('admin', 'licenses');
1662
- }
1663
- license(id) {
1664
- return new APIAdminResourceLicense(this, id);
1665
- }
1666
- maintenance() {
1667
- return new APIResource(this).push('admin', 'maintenance');
1668
- }
1669
- marketShares() {
1670
- return new APIList(this).push('admin', 'market-shares');
1671
- }
1672
- notificationPlans() {
1673
- return new APIAdminListNotificationPlans(this);
1674
- }
1675
- notificationPlan(id) {
1676
- return new APIAdminResourceNotificationPlan(this, id);
1677
- }
1678
- overview() {
1679
- return new APIResource(this).push('admin', 'overview');
1680
- }
1681
- pools() {
1682
- return new APIList(this).push('admin', 'pools');
1683
- }
1684
- pool(id) {
1685
- return new APIResource(this).push('admin', 'pools', id);
1686
- }
1687
- projects() {
1688
- return new APIList(this).push('projects');
1689
- }
1690
- project(id) {
1691
- return new APIResourceProject(this, id);
1692
- }
1693
- roles() {
1694
- return new APIList(this).push('admin', 'roles');
1695
- }
1696
- runs() {
1697
- return new APIAdminListRuns(this);
1698
- }
1699
- run(id) {
1700
- return new APIAdminResourceRunStandalone(this, id);
1701
- }
1702
- samples() {
1703
- return new APIList(this).push('admin', 'samples');
1704
- }
1705
- sample(id) {
1706
- if (id == null) {
1707
- throw new Error('Resource ID cannot be null!');
1708
- }
1709
- return new APIResource(this).push('admin', 'samples', id);
1710
- }
1711
- services() {
1712
- return new APIAdminListServices(this);
1713
- }
1714
- service(id) {
1715
- return new APIAdminResourceService(this, id);
1716
- }
1717
- settings() {
1718
- return new APIResource(this).push('admin', 'settings');
1719
- }
1720
- statistics() {
1721
- return new APIAdminListStatistics(this);
1722
- }
1723
- users() {
1724
- return new APIList(this).push('users');
1725
- }
1726
- createUser() {
1727
- return new APIList(this).push('admin', 'users').post();
1728
- }
1729
- user(id) {
1730
- return new APIAdminResourceUser(this, id);
1731
- }
1744
+ class APIResourceUserSession extends APIResource {
1745
+ constructor(parent) {
1746
+ super(parent);
1747
+ this.push('user-sessions');
1748
+ }
1749
+ login(data) {
1750
+ return new APIResource(this).push('login').post().data(data);
1751
+ }
1752
+ logout() {
1753
+ return new APIResource(this).push('logout').post();
1754
+ }
1755
+ sso(name) {
1756
+ return new APIResource(this).push(name + '-login');
1757
+ }
1758
+ portalLogin() {
1759
+ return new APIResource(this).push('portal-login').post();
1760
+ }
1732
1761
  }
1733
1762
 
1734
- class APIResourceAccount extends APIResource {
1735
- constructor(parent, id) {
1736
- if (id == null) {
1737
- throw new Error('Resource ID cannot be null!');
1738
- }
1739
- super(parent);
1740
- this.push('accounts', id);
1741
- }
1742
- concurrencyStatus() {
1743
- return new APIResource(this).push('concurrency-status');
1744
- }
1745
- preferences() {
1746
- return new APIResource(this).push('preferences');
1747
- }
1763
+ if (globalThis.isNodeJs) {
1764
+ axios__default["default"].defaults.headers.common['User-Agent'] = `Bitbar Cloud API Client for JavaScript v${version}`;
1748
1765
  }
1749
-
1750
- if (global.isNodeJs) {
1751
- axios.defaults.headers.common['User-Agent'] = `Bitbar Cloud API Client for JavaScript v${version}`;
1752
- }
1753
- axios.defaults.maxContentLength = 1073741824;
1754
- class API {
1755
- constructor(config) {
1756
- if (config == null) {
1757
- throw new Error('config cannot be empty');
1758
- }
1759
- this.config = config;
1760
- this.axiosConfig = {};
1761
- if (this.config.cloudUrl == null) {
1762
- throw new TypeError('cloudUrl cannot be empty');
1763
- }
1764
- else if (typeof this.config.cloudUrl !== 'string') {
1765
- throw new TypeError('cloudUrl must be a string');
1766
- }
1767
- else if (!/^https?:\/\/.{2,}/.test(this.config.cloudUrl)) {
1768
- throw new Error("cloudUrl doesn't look like a URL");
1769
- }
1770
- this.axiosConfig.baseURL = this.config.cloudUrl.replace(/\/+$/, '') + '/api';
1771
- this.config.v2 = !!this.config.v2;
1772
- if (this.config.v2) {
1773
- this.axiosConfig.baseURL += '/v2';
1774
- }
1775
- if (this.config.apiKey) {
1776
- if (typeof this.config.apiKey !== 'string') {
1777
- throw new TypeError('apiKey must be a string');
1778
- }
1779
- else if (!/^[A-Za-z0-9]{32}$/.test(this.config.apiKey)) {
1780
- throw new Error("apiKey is in the wrong format");
1781
- }
1782
- this.axiosConfig.auth = {
1783
- username: this.config.apiKey,
1784
- password: ''
1785
- };
1786
- }
1787
- this.axiosConfig.withCredentials = config.withCredentials == null ? false : config.withCredentials;
1788
- this.axios = axios.create(this.axiosConfig);
1789
- }
1790
- userSession() {
1791
- return new APIResourceUserSession(this);
1792
- }
1793
- user(id) {
1794
- return new APIResourceUser(this, id);
1795
- }
1796
- users() {
1797
- return new APIListUsers(this);
1798
- }
1799
- account(id) {
1800
- return new APIResourceAccount(this, id);
1801
- }
1802
- me() {
1803
- return this.user('me');
1804
- }
1805
- admin() {
1806
- return new APIAdminResource(this);
1807
- }
1808
- devices() {
1809
- return new APIListDevices(this);
1810
- }
1811
- device(id) {
1812
- return new APIResourceDevice(this, id);
1813
- }
1814
- deviceGroups() {
1815
- return new APIList(this).push('device-groups');
1816
- }
1817
- deviceGroup(id) {
1818
- return new APIResourceDeviceGroup(this, id);
1819
- }
1820
- deviceSessions() {
1821
- return new APIList(this).push('device-sessions');
1822
- }
1823
- deviceSession(id) {
1824
- return new APIResourceDeviceSession(this, id);
1825
- }
1826
- labelGroups() {
1827
- return new APIList(this).push('label-groups');
1828
- }
1829
- deviceStatistics() {
1830
- return new APIList(this).push('device-statistics');
1831
- }
1832
- enums() {
1833
- return new APIResource(this).push('enums');
1834
- }
1835
- licenses() {
1836
- return new APIResource(this).push('licenses');
1837
- }
1838
- labels() {
1839
- return new APIList(this).push('labels');
1840
- }
1766
+ axios__default["default"].defaults.maxContentLength = 1073741824;
1767
+ class API {
1768
+ constructor(config) {
1769
+ this.config = config;
1770
+ this.axiosConfig = {};
1771
+ if (config == null) {
1772
+ throw new Error('config cannot be empty');
1773
+ }
1774
+ else if (this.config.cloudUrl == null) {
1775
+ throw new TypeError('cloudUrl cannot be empty');
1776
+ }
1777
+ else if (typeof this.config.cloudUrl !== 'string') {
1778
+ throw new TypeError('cloudUrl must be a string');
1779
+ }
1780
+ else if (!/^https?:\/\/.{2,}/.test(this.config.cloudUrl)) {
1781
+ throw new Error(`cloudUrl doesn't look like a URL`);
1782
+ }
1783
+ this.axiosConfig.baseURL = this.config.cloudUrl.replace(/\/+$/, '') + '/api';
1784
+ this.config.v2 = !!this.config.v2;
1785
+ if (this.config.v2) {
1786
+ this.axiosConfig.baseURL += '/v2';
1787
+ }
1788
+ if (this.config.apiKey) {
1789
+ if (typeof this.config.apiKey !== 'string') {
1790
+ throw new TypeError('apiKey must be a string');
1791
+ }
1792
+ else if (!/^[A-Za-z0-9]{32}$/.test(this.config.apiKey)) {
1793
+ throw new Error('apiKey is in the wrong format');
1794
+ }
1795
+ this.axiosConfig.auth = {
1796
+ username: this.config.apiKey,
1797
+ password: ''
1798
+ };
1799
+ }
1800
+ this.axiosConfig.withCredentials = config.withCredentials == null ? false : config.withCredentials;
1801
+ this.axios = axios__default["default"].create(this.axiosConfig);
1802
+ }
1803
+ get baseUrl() {
1804
+ return this.axiosConfig.baseURL;
1805
+ }
1806
+ account(id) {
1807
+ return new APIResourceAccount(this, id);
1808
+ }
1809
+ admin() {
1810
+ return new APIAdminResource(this);
1811
+ }
1812
+ broker() {
1813
+ return new APIResourceBroker(this);
1814
+ }
1815
+ clusters() {
1816
+ return new APIList(this).push('clusters');
1817
+ }
1818
+ cluster(id) {
1819
+ return new APIAdminResourceCluster(this, id);
1820
+ }
1821
+ device(id) {
1822
+ return new APIResourceDevice(this, id);
1823
+ }
1824
+ deviceGroup(id) {
1825
+ return new APIResourceDeviceGroup(this, id);
1826
+ }
1827
+ deviceGroups() {
1828
+ return new APIList(this).push('device-groups');
1829
+ }
1830
+ devices() {
1831
+ return new APIListDevices(this);
1832
+ }
1833
+ deviceSession(id) {
1834
+ return new APIResourceDeviceSession(this, id);
1835
+ }
1836
+ deviceSessions() {
1837
+ return new APIList(this).push('device-sessions');
1838
+ }
1839
+ deviceStatistics() {
1840
+ return new APIList(this).push('device-statistics');
1841
+ }
1842
+ enums() {
1843
+ return new APIResource(this).push('enums');
1844
+ }
1845
+ files() {
1846
+ return new APIList(this).push('files');
1847
+ }
1848
+ file(id) {
1849
+ return new APIResourceFile(this, id);
1850
+ }
1851
+ labelGroups() {
1852
+ return new APIList(this).push('label-groups');
1853
+ }
1854
+ labelGroup(id) {
1855
+ return new APIResourceLabelGroup(this, id);
1856
+ }
1857
+ labels() {
1858
+ return new APIList(this).push('labels');
1859
+ }
1860
+ licenses() {
1861
+ return new APIResource(this).push('licenses');
1862
+ }
1863
+ license() {
1864
+ return new APIResource(this).push('license');
1865
+ }
1866
+ me() {
1867
+ return this.user('me');
1868
+ }
1869
+ projects() {
1870
+ return new APIList(this).push('projects');
1871
+ }
1872
+ project(id) {
1873
+ return new APIResourceProject(this, id);
1874
+ }
1875
+ properties() {
1876
+ return new APIListProperties(this);
1877
+ }
1878
+ property(id) {
1879
+ return new APIResource(this).push('properties', id);
1880
+ }
1881
+ run(id) {
1882
+ return new APIResourceRun(this, id);
1883
+ }
1884
+ services() {
1885
+ return new APIListServices(this);
1886
+ }
1887
+ user(id) {
1888
+ return new APIResourceUser(this, id);
1889
+ }
1890
+ users() {
1891
+ return new APIListUsers(this);
1892
+ }
1893
+ userSession() {
1894
+ return new APIResourceUserSession(this);
1895
+ }
1841
1896
  }
1842
1897
 
1843
- const CloudAPIClient = {
1844
- API,
1845
- FilterBuilder
1898
+ const CloudAPIClient = {
1899
+ API,
1900
+ FilterBuilder
1846
1901
  };
1847
1902
 
1848
1903
  return CloudAPIClient;
1849
1904
 
1850
- })));
1905
+ }));
1851
1906
  //# sourceMappingURL=bitbar-cloud-api-client.js.map