Client for System Information RESTful API
parent
d05a72e9af
commit
b565805057
|
|
@ -1,3 +1,4 @@
|
|||
import { CategorizationApiClient } from "./clients/categorization-api";
|
||||
import { SystemInformationClient } from "./clients/systeminformation-api";
|
||||
|
||||
export { CategorizationApiClient };
|
||||
export { CategorizationApiClient, SystemInformationClient };
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
import {
|
||||
ApiResponse,
|
||||
LibreCcmApiClient,
|
||||
} from "@libreccm/ccm-apiclient-commons";
|
||||
|
||||
import * as Constants from "../constants";
|
||||
|
||||
export class SystemInformationClient {
|
||||
#apiClient: LibreCcmApiClient;
|
||||
|
||||
readonly #SYSINFO_API_PREFIX = `${Constants.ADMIN_API_PREFIX}/systeminformation`;
|
||||
|
||||
constructor(apiClient: LibreCcmApiClient) {
|
||||
this.#apiClient = apiClient;
|
||||
}
|
||||
|
||||
async getSystemInformation(): Promise<Record<string, string>> {
|
||||
try {
|
||||
const response: ApiResponse = await this.#apiClient.get(
|
||||
this.#SYSINFO_API_PREFIX
|
||||
);
|
||||
|
||||
if (response.ok) {
|
||||
return (await response.json()) as Record<string, string>;
|
||||
} else {
|
||||
throw `Failed get system information:
|
||||
${response.status} ${response.statusText}`;
|
||||
}
|
||||
} catch (err) {
|
||||
throw `Failed to get system information: ${err}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue