@edgeiq/edgeiq-api-js 1.11.9 → 1.11.11

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.
@@ -3,7 +3,7 @@ import { BaseModelInterface } from '../core/ModelClass';
3
3
  import { GatewayCommand, GatewayCommandRequest } from '../gatewayCommands/models';
4
4
  import { BulkActionResponse, PaginationFilter } from '../models';
5
5
  import { Lwm2mObjectLinks } from '../lwm2m/models';
6
- import { DevicesFilters, Device, DeviceInput, PaginatedDevices, DeviceExportColumnn } from './models';
6
+ import { DevicesFilters, Device, DeviceInput, PaginatedDevices, DeviceExportColumnn, DeviceUptime, DeviceUptimeHistory } from './models';
7
7
  import { CommandExecutionsFilters, PaginatedCommandExecutions } from '../commandExecutions/models';
8
8
  import { AwsThingGroup } from '../models';
9
9
  interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, DevicesFilters, PaginatedDevices> {
@@ -44,6 +44,8 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
44
44
  bulkExecuteWorkflow(workflowId: string, ids: string[]): Promise<BulkActionResponse>;
45
45
  revokeCertificate(id: string, certificateId: string, revoke: boolean): Promise<string>;
46
46
  getExportColumns(): Promise<DeviceExportColumnn[]>;
47
+ getDeviceUptime(id: string, start: string, end: string): Promise<DeviceUptime>;
48
+ getDeviceUptimeHistory(id: string, start: string, end: string): Promise<DeviceUptimeHistory>;
47
49
  }
48
50
  export declare const Devices: DevicesInterface;
49
51
  export {};
@@ -683,4 +683,36 @@ export const Devices = class extends BaseModelClass {
683
683
  }
684
684
  });
685
685
  }
686
+ static getDeviceUptime(id, start, end) {
687
+ return __awaiter(this, void 0, void 0, function* () {
688
+ try {
689
+ this.logAction('Getting device uptime');
690
+ const axios = EdgeIQAPI.getAxios();
691
+ const result = yield axios.get(`${Endpoints.device}/${id}/uptime?start=${start}&end=${end}`);
692
+ return result === null || result === void 0 ? void 0 : result.data;
693
+ }
694
+ catch (error) {
695
+ if (isApiError(error)) {
696
+ throw error;
697
+ }
698
+ throw error;
699
+ }
700
+ });
701
+ }
702
+ static getDeviceUptimeHistory(id, start, end) {
703
+ return __awaiter(this, void 0, void 0, function* () {
704
+ try {
705
+ this.logAction('Getting device uptime');
706
+ const axios = EdgeIQAPI.getAxios();
707
+ const result = yield axios.get(`${Endpoints.device}/${id}/uptime_history?start=${start}&end=${end}`);
708
+ return result === null || result === void 0 ? void 0 : result.data;
709
+ }
710
+ catch (error) {
711
+ if (isApiError(error)) {
712
+ throw error;
713
+ }
714
+ throw error;
715
+ }
716
+ });
717
+ }
686
718
  };
@@ -48,6 +48,17 @@ export interface DeviceExportColumnn {
48
48
  name: string;
49
49
  is_default: boolean;
50
50
  }
51
+ export interface DeviceUptime {
52
+ start: string;
53
+ end: string;
54
+ uptime: number;
55
+ }
56
+ export interface DeviceUptimeHistory {
57
+ categories: unknown;
58
+ category_percentage: string;
59
+ data: unknown;
60
+ measure: string;
61
+ }
51
62
  export interface DeviceInput {
52
63
  name: string;
53
64
  unique_id: string;
@@ -1,9 +1,9 @@
1
1
  import { BaseModelInterface } from '../core/ModelClass';
2
2
  import { BulkActionResponse, PaginationFilter } from '../models';
3
- import { Report, ReportInput, ReportsFilters, PaginatedReports } from './models';
3
+ import { Report, ReportInput, ReportsFilters, PaginatedReports, PaginatedHeartbeats } from './models';
4
4
  interface ReportsInterface extends BaseModelInterface<Report, ReportInput, ReportsFilters, PaginatedReports> {
5
5
  deleteMultiple(ids: string[]): Promise<BulkActionResponse>;
6
- listHeartbeats(filters: ReportsFilters, pagination: PaginationFilter): Promise<PaginatedReports>;
6
+ listHeartbeats(filters: ReportsFilters, pagination: PaginationFilter): Promise<PaginatedHeartbeats>;
7
7
  }
8
8
  export declare const Reports: ReportsInterface;
9
9
  export {};
@@ -60,13 +60,13 @@ export const Reports = class extends BaseModelClass {
60
60
  var _a, _b, _c, _d;
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
62
  try {
63
- this.logAction(`Listing reports with following filters: ${filters !== null && filters !== void 0 ? filters : '{}'}.\n And pagination ${pagination !== null && pagination !== void 0 ? pagination : '{}'}`);
63
+ this.logAction(`Listing heartbeats with following filters: ${filters !== null && filters !== void 0 ? filters : '{}'}.\n And pagination ${pagination !== null && pagination !== void 0 ? pagination : '{}'}`);
64
64
  const axios = EdgeIQAPI.getAxios();
65
65
  const result = yield axios.get(Endpoints.heartbeats, {
66
66
  params: parseFilters(filters, pagination),
67
67
  });
68
68
  return {
69
- reports: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
69
+ heartbeats: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
70
70
  pagination: {
71
71
  page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
72
72
  itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
@@ -12,13 +12,32 @@ export interface ReportInput {
12
12
  }
13
13
  export interface Report extends ReportInput, Base {
14
14
  }
15
+ export interface Heartbeat extends Base {
16
+ cpu_usage: number;
17
+ device_id: string;
18
+ device_type_id: string;
19
+ disk_free: number;
20
+ disk_size: number;
21
+ disk_usage: number;
22
+ id: string;
23
+ ram_usage: number;
24
+ unique_id: string;
25
+ }
15
26
  export interface ReportsFilters extends Filters {
16
27
  device_id?: Filter;
17
28
  device_name?: Filter;
18
29
  device_datetime?: Filter;
19
30
  type?: Filter;
20
31
  }
32
+ export interface HeartbeatsFilters extends Filters {
33
+ device_id?: Filter;
34
+ type?: Filter;
35
+ }
21
36
  export interface PaginatedReports {
22
37
  reports: Report[];
23
38
  pagination: Pagination;
24
39
  }
40
+ export interface PaginatedHeartbeats {
41
+ heartbeats: Heartbeat[];
42
+ pagination: Pagination;
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeiq/edgeiq-api-js",
3
- "version": "1.11.9",
3
+ "version": "1.11.11",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",