docs: add TSDoc to core components
- Added detailed JSDoc documentation to all core datasource classes in src/datasources/ - Documented execution logic classes in src/execution/ - Added TSDoc to API utility functions and resolvers in src/api/ - Documented shared models and enums in src/model/
This commit is contained in:
parent
3c3cb7c753
commit
0acef818c6
27 changed files with 689 additions and 19 deletions
|
|
@ -1,19 +1,42 @@
|
|||
import {GraphQLResolveInfo} from "graphql";
|
||||
import {getRequestedFields} from "../api/graphql_utils.js";
|
||||
|
||||
/**
|
||||
* Helper class to map GraphQL request information to the fields needed from Zabbix.
|
||||
*/
|
||||
export class GraphqlParamsToNeededZabbixOutput {
|
||||
/**
|
||||
* Maps the requested fields for allHosts query.
|
||||
* @param info - The GraphQL resolve info.
|
||||
* @returns An array of field names.
|
||||
*/
|
||||
static mapAllHosts(info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the requested fields for allDevices query.
|
||||
* @param info - The GraphQL resolve info.
|
||||
* @returns An array of field names.
|
||||
*/
|
||||
static mapAllDevices(info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the requested fields for allHostGroups query.
|
||||
* @param info - The GraphQL resolve info.
|
||||
* @returns An array of field names.
|
||||
*/
|
||||
static mapAllHostGroups(info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the requested fields for templates query.
|
||||
* @param info - The GraphQL resolve info.
|
||||
* @returns An array of field names.
|
||||
*/
|
||||
static mapTemplates(info: GraphQLResolveInfo): string[] {
|
||||
return getRequestedFields(info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,18 @@ export const zabbixPrivilegeEscalationToken = Config.ZABBIX_PRIVILEGE_ESCALATION
|
|||
export const ZABBIX_EDGE_DEVICE_BASE_GROUP = Config.ZABBIX_EDGE_DEVICE_BASE_GROUP || Config.ZABBIX_ROADWORK_BASE_GROUP || "Roadwork"
|
||||
export const FIND_ZABBIX_EDGE_DEVICE_BASE_GROUP_PREFIX = new RegExp(`^(${ZABBIX_EDGE_DEVICE_BASE_GROUP})\/`)
|
||||
|
||||
/**
|
||||
* Data source for interacting with the Zabbix API.
|
||||
* Extends RESTDataSource to handle JSON-RPC requests to Zabbix.
|
||||
*/
|
||||
export class ZabbixAPI
|
||||
extends RESTDataSource {
|
||||
private static readonly MAX_LOG_REQUEST_BODY_LIMIT_LENGTH = 500
|
||||
|
||||
/**
|
||||
* @param baseURL - The base URL of the Zabbix API.
|
||||
* @param config - Optional data source configuration.
|
||||
*/
|
||||
constructor(public baseURL: string, config?: DataSourceConfig) {
|
||||
super(config);
|
||||
logger.info("Connecting to Zabbix at url=" + this.baseURL)
|
||||
|
|
@ -82,6 +90,10 @@ export class ZabbixAPI
|
|||
|
||||
private static version: string | undefined
|
||||
|
||||
/**
|
||||
* Retrieves the Zabbix API version.
|
||||
* @returns A promise that resolves to the version string.
|
||||
*/
|
||||
async getVersion(): Promise<string> {
|
||||
if (!ZabbixAPI.version) {
|
||||
const response = await this.requestByPath<string>("apiinfo.version")
|
||||
|
|
@ -94,14 +106,39 @@ export class ZabbixAPI
|
|||
return ZabbixAPI.version
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a Zabbix API request.
|
||||
* @param zabbixRequest - The request object to execute.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param throwApiError - Whether to throw an error if the request fails (default: true).
|
||||
* @param output - The list of fields to return.
|
||||
* @returns A promise that resolves to the result or an error result.
|
||||
*/
|
||||
async executeRequest<T extends ZabbixResult, A extends ParsedArgs>(zabbixRequest: ZabbixRequest<T, A>, args?: A, throwApiError: boolean = true, output?: string[]): Promise<T | ZabbixErrorResult> {
|
||||
return throwApiError ? zabbixRequest.executeRequestThrowError(this, args, output) : zabbixRequest.executeRequestReturnError(this, args, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a Zabbix API request by its method path.
|
||||
* @param path - The Zabbix API method path.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookies - Optional session cookies.
|
||||
* @param throwApiError - Whether to throw an error if the request fails (default: true).
|
||||
* @param output - The list of fields to return.
|
||||
* @returns A promise that resolves to the result or an error result.
|
||||
*/
|
||||
async requestByPath<T extends ZabbixResult, A extends ParsedArgs = ParsedArgs>(path: string, args?: A, authToken?: string | null, cookies?: string, throwApiError: boolean = true, output?: string[]) {
|
||||
return this.executeRequest<T, A>(new ZabbixRequest<T>(path, authToken, cookies), args, throwApiError, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves locations from host inventory.
|
||||
* @param args - The parsed arguments for filtering locations.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookies - Optional session cookies.
|
||||
* @returns A promise that resolves to an array of location objects.
|
||||
*/
|
||||
async getLocations(args?: ParsedArgs, authToken?: string, cookies?: string) {
|
||||
const hosts_promise = this.requestByPath("host.get", args, authToken, cookies);
|
||||
return hosts_promise.then(response => {
|
||||
|
|
|
|||
|
|
@ -16,10 +16,23 @@ export interface ZabbixExportValue extends ZabbixValue, ZabbixResult {
|
|||
itemid?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for querying history from Zabbix.
|
||||
*/
|
||||
export class ZabbixHistoryGetParams extends ParsedArgs {
|
||||
time_from_ms: number | undefined
|
||||
time_till_ms: number | undefined
|
||||
|
||||
/**
|
||||
* @param itemids - The IDs of the items to query history for.
|
||||
* @param output - The list of fields to return.
|
||||
* @param limit - The maximum number of values to return.
|
||||
* @param history - The storage item type (e.g., float, integer, character, text, log).
|
||||
* @param time_from - The start time for the history query.
|
||||
* @param time_until - The end time for the history query.
|
||||
* @param sortfield - The field to sort the results by.
|
||||
* @param sortorder - The sort order (ASC or DESC).
|
||||
*/
|
||||
constructor(public itemids: number[] | number | string | string[],
|
||||
public output: string[] = ["value", "itemid", "clock", "ns"],
|
||||
public limit: number | null = Array.isArray(itemids) ? itemids.length : 1,
|
||||
|
|
@ -35,7 +48,14 @@ export class ZabbixHistoryGetParams extends ParsedArgs {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to query history from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryHistoryRequest extends ZabbixRequest<ZabbixExportValue[], ZabbixHistoryGetParams> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("history.get", authToken, cookie);
|
||||
}
|
||||
|
|
@ -65,7 +85,16 @@ export interface ZabbixHistoryPushResult {
|
|||
error?: ApiError | string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for pushing history to Zabbix.
|
||||
*/
|
||||
export class ZabbixHistoryPushParams extends ParsedArgs {
|
||||
/**
|
||||
* @param values - The history values to push.
|
||||
* @param itemid - Optional item ID to push history for.
|
||||
* @param key - Optional item key to push history for.
|
||||
* @param host - Optional host name to push history for.
|
||||
*/
|
||||
constructor(public values: ZabbixHistoryPushInput[], public itemid?: string,
|
||||
public key?: string,
|
||||
public host?: string,) {
|
||||
|
|
@ -73,7 +102,14 @@ export class ZabbixHistoryPushParams extends ParsedArgs {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to push history to Zabbix.
|
||||
*/
|
||||
export class ZabbixHistoryPushRequest extends ZabbixRequest<ZabbixHistoryPushResult, ZabbixHistoryPushParams> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string) {
|
||||
super("history.push", authToken, cookie);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,28 @@ const hostGroupReadWritePermissions = {
|
|||
}]
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to create a host group in Zabbix.
|
||||
*/
|
||||
export class ZabbixCreateHostGroupRequest extends ZabbixRequestWithPermissions<CreateHostGroupResult> {
|
||||
/**
|
||||
* @param _authToken - Ignored, as privilege escalation token is used.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(_authToken?: string | null, cookie?: string) {
|
||||
super("hostgroup.create", zabbixPrivilegeEscalationToken, cookie, hostGroupReadWritePermissions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for querying host groups from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryHostgroupsParams extends ParsedArgs {
|
||||
search_name: string | undefined
|
||||
|
||||
/**
|
||||
* @param args - The raw arguments.
|
||||
*/
|
||||
constructor(args?: any) {
|
||||
super(args);
|
||||
if ("search_name" in args && typeof (args.search_name) == "string") {
|
||||
|
|
@ -45,8 +58,16 @@ export type ZabbixQueryHostgroupsResult = {
|
|||
uuid: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to query host groups from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryHostgroupsRequest extends ZabbixRequestWithPermissions<ZabbixQueryHostgroupsResult[],
|
||||
ZabbixQueryHostgroupsParams> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
* @param hostGroupReadPermissions - Optional host group read permissions.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null, hostGroupReadPermissions?: any) {
|
||||
super("hostgroup.get", authToken, cookie, hostGroupReadPermissions,);
|
||||
}
|
||||
|
|
@ -69,7 +90,14 @@ export class ZabbixQueryHostgroupsRequest extends ZabbixRequestWithPermissions<Z
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to delete host groups in Zabbix.
|
||||
*/
|
||||
export class ZabbixDeleteHostGroupsRequest extends ZabbixRequestWithPermissions<{ groupids: string[] }> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("hostgroup.delete", authToken, cookie, hostGroupReadWritePermissions);
|
||||
}
|
||||
|
|
@ -84,6 +112,14 @@ export class GroupHelper {
|
|||
return groupName.replace(FIND_ZABBIX_EDGE_DEVICE_BASE_GROUP_PREFIX, "")
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds host group IDs by their names.
|
||||
* @param groupNames - The names of the host groups to find.
|
||||
* @param zabbixApi - The Zabbix API instance.
|
||||
* @param zabbixAuthToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
* @returns A promise that resolves to an array of host group IDs.
|
||||
*/
|
||||
public static async findHostGroupIdsByName(groupNames: string[], zabbixApi: ZabbixAPI, zabbixAuthToken?: string, cookie?: string) {
|
||||
let result: number[] = []
|
||||
for (let groupName of groupNames) {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,17 @@ import {ZabbixHistoryGetParams, ZabbixQueryHistoryRequest} from "./zabbix-histor
|
|||
import {ZabbixQueryItemRequest} from "./zabbix-templates.js";
|
||||
|
||||
|
||||
/**
|
||||
* Generic request to query hosts from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryHostsGenericRequest<T extends ZabbixResult, A extends ParsedArgs = ParsedArgs> extends ZabbixRequest<T, A> {
|
||||
public static PATH = "host.get";
|
||||
|
||||
/**
|
||||
* @param path - The Zabbix API method path.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(path: string, authToken?: string | null, cookie?: string | null) {
|
||||
super(path, authToken, cookie);
|
||||
this.skippableZabbixParams.set("selectParentTemplates", "parentTemplates");
|
||||
|
|
@ -25,10 +33,23 @@ export class ZabbixQueryHostsGenericRequest<T extends ZabbixResult, A extends Pa
|
|||
this.impliedFields.set("hostType", ["tags"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns the result or an error.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param output - The list of fields to return.
|
||||
* @returns A promise that resolves to the result or an error.
|
||||
*/
|
||||
async executeRequestReturnError(zabbixAPI: ZabbixAPI, args?: A, output?: string[]): Promise<ZabbixErrorResult | T> {
|
||||
return await super.executeRequestReturnError(zabbixAPI, args, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the parameters for the Zabbix API request.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param output - The list of fields to return.
|
||||
* @returns The Zabbix parameters.
|
||||
*/
|
||||
createZabbixParams(args?: A, output?: string[]): ZabbixParams {
|
||||
const params: any = {
|
||||
...super.createZabbixParams(args),
|
||||
|
|
@ -58,9 +79,16 @@ export class ZabbixQueryHostsGenericRequest<T extends ZabbixResult, A extends Pa
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request to query host metadata from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryHostsMetaRequest extends ZabbixQueryHostsGenericRequest<Host[]> {
|
||||
public static PATH = "host.get.meta";
|
||||
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super(ZabbixQueryHostsMetaRequest.PATH, authToken, cookie);
|
||||
}
|
||||
|
|
@ -74,7 +102,15 @@ export class ZabbixQueryHostsMetaRequest extends ZabbixQueryHostsGenericRequest<
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generic request to query hosts with their items from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryHostsGenericRequestWithItems<T extends ZabbixResult, A extends ParsedArgs = ParsedArgs> extends ZabbixQueryHostsGenericRequest<T, A> {
|
||||
/**
|
||||
* @param path - The Zabbix API method path.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(path: string, authToken?: string | null, cookie?: string) {
|
||||
super(path, authToken, cookie);
|
||||
this.skippableZabbixParams.set("selectItems", "items");
|
||||
|
|
@ -167,7 +203,15 @@ export class ZabbixQueryHostsGenericRequestWithItems<T extends ZabbixResult, A e
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic request to query hosts with their items and inventory from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryHostsGenericRequestWithItemsAndInventory<T extends ZabbixResult, A extends ParsedArgs = ParsedArgs> extends ZabbixQueryHostsGenericRequestWithItems<T, A> {
|
||||
/**
|
||||
* @param path - The Zabbix API method path.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(path: string, authToken?: string | null, cookie?: string) {
|
||||
super(path, authToken, cookie);
|
||||
this.skippableZabbixParams.set("selectInventory", "inventory");
|
||||
|
|
@ -189,7 +233,13 @@ export class ZabbixQueryHostsRequestWithItemsAndInventory extends ZabbixQueryHos
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for querying devices.
|
||||
*/
|
||||
export class ZabbixQueryDevicesArgs extends ParsedArgs {
|
||||
/**
|
||||
* @param args - The raw arguments.
|
||||
*/
|
||||
constructor(public args?: any) {
|
||||
if (!args?.tag_deviceType ||
|
||||
(Array.isArray(args.tag_deviceType) && !args.tag_deviceType.length)) {
|
||||
|
|
@ -199,7 +249,14 @@ export class ZabbixQueryDevicesArgs extends ParsedArgs {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to query devices from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryDevices extends ZabbixQueryHostsGenericRequestWithItemsAndInventory<Device[], ZabbixQueryDevicesArgs> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string) {
|
||||
super("host.get.with_items", authToken, cookie);
|
||||
}
|
||||
|
|
@ -272,7 +329,14 @@ class ZabbixCreateHostParams implements ZabbixParams {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request to create a host in Zabbix.
|
||||
*/
|
||||
export class ZabbixCreateHostRequest extends ZabbixRequest<CreateHostResponse> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string) {
|
||||
super("host.create", authToken, cookie);
|
||||
}
|
||||
|
|
@ -286,7 +350,14 @@ export class ZabbixCreateHostRequest extends ZabbixRequest<CreateHostResponse> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to delete hosts in Zabbix.
|
||||
*/
|
||||
export class ZabbixDeleteHostsRequest extends ZabbixRequest<{ hostids: string[] }> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("host.delete", authToken, cookie);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,23 @@ import {ParsedArgs, ZabbixRequest} from "./zabbix-request.js";
|
|||
import {ZabbixItem} from "../schema/generated/graphql.js";
|
||||
|
||||
|
||||
/**
|
||||
* Request to query items from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryItemsRequest extends ZabbixRequest<ZabbixItem[]> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string) {
|
||||
super("item.get", authToken, cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the parameters for the Zabbix API request.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @returns The Zabbix parameters.
|
||||
*/
|
||||
createZabbixParams(args?: ParsedArgs) {
|
||||
return {
|
||||
"templated": false,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
import {ParsedArgs, ZabbixParams, ZabbixRequest} from "./zabbix-request.js";
|
||||
import {UserRoleModule} from "../schema/generated/graphql.js";
|
||||
|
||||
/**
|
||||
* Request to query modules from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryModulesRequest extends ZabbixRequest<UserRoleModule[]> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("module.get", authToken, cookie);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,18 +5,38 @@ import {ApiErrorCode, PermissionNumber} from "../model/model_enum_values.js";
|
|||
import {Config} from "../common_utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Base class for Zabbix requests that require specific user permissions.
|
||||
*/
|
||||
export class ZabbixRequestWithPermissions<T extends ZabbixResult, A extends ParsedArgs = ParsedArgs> extends ZabbixRequest<T, A> {
|
||||
|
||||
/**
|
||||
* @param path - The Zabbix API method path.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
* @param permissionsNeeded - The permissions required to execute this request.
|
||||
*/
|
||||
constructor(public path: string, public authToken?: string | null, public cookie?: string | null,
|
||||
protected permissionsNeeded?: QueryHasPermissionsArgs) {
|
||||
super(path, authToken, cookie);
|
||||
}
|
||||
/**
|
||||
* Prepares the request by checking user permissions.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @param _args - The parsed arguments for the request.
|
||||
* @returns A promise that resolves to the result or an error if permissions are missing.
|
||||
*/
|
||||
async prepare(zabbixAPI: ZabbixAPI, _args?: A): Promise<T | ZabbixErrorResult | undefined> {
|
||||
// If prepare returns something else than undefined, the execution will be skipped and the
|
||||
// result returned
|
||||
this.prepResult = await this.assureUserPermissions(zabbixAPI);
|
||||
return this.prepResult;
|
||||
}
|
||||
/**
|
||||
* Ensures that the user has the required permissions.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @returns A promise that resolves to undefined if permissions are granted, or an error otherwise.
|
||||
*/
|
||||
async assureUserPermissions(zabbixAPI: ZabbixAPI) {
|
||||
if (this.authToken && this.authToken === Config.ZABBIX_PRIVILEGE_ESCALATION_TOKEN) {
|
||||
// Bypass permission check for the privilege escalation token as it is assumed to have required rights
|
||||
|
|
@ -104,6 +124,14 @@ export class ZabbixPermissionsHelper {
|
|||
private static permissionObjectNameCache: Map<string, string | null> = new Map()
|
||||
public static ZABBIX_PERMISSION_TEMPLATE_GROUP_NAME_PREFIX = Config.ZABBIX_PERMISSION_TEMPLATE_GROUP_NAME_PREFIX
|
||||
|
||||
/**
|
||||
* Retrieves permissions for the current user.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @param zabbixAuthToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
* @param objectNames - Optional filter for object names.
|
||||
* @returns A promise that resolves to an array of user permissions.
|
||||
*/
|
||||
public static async getUserPermissions(zabbixAPI: ZabbixAPI, zabbixAuthToken?: string, cookie?: string,
|
||||
objectNames?: InputMaybe<string[]> | undefined): Promise<UserPermission[]> {
|
||||
return Array.from((await this.getUserPermissionNumbers(zabbixAPI, zabbixAuthToken, cookie, objectNames)).entries()).map(value => {
|
||||
|
|
@ -211,6 +239,14 @@ export class ZabbixPermissionsHelper {
|
|||
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user has the required permissions.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @param args - The permissions to check.
|
||||
* @param zabbixAuthToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
* @returns A promise that resolves to true if the user has all required permissions, false otherwise.
|
||||
*/
|
||||
public static async hasUserPermissions(zabbixAPI: ZabbixAPI, args: QueryHasPermissionsArgs, zabbixAuthToken?: string | null, cookie?: string | null): Promise<boolean> {
|
||||
let permissions = await this.getUserPermissionNumbers(zabbixAPI, zabbixAuthToken, cookie);
|
||||
for (const permission of args.permissions) {
|
||||
|
|
|
|||
|
|
@ -33,11 +33,18 @@ export interface ZabbixWithTagsParams extends ZabbixParams {
|
|||
tags?: { tag: string; operator: number; value?: any; }[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Parser for arguments passed to Zabbix requests.
|
||||
* Handles Zabbix-specific argument mapping like name_pattern, tag filters, and field filters.
|
||||
*/
|
||||
export class ParsedArgs {
|
||||
public name_pattern?: string
|
||||
public distinct_by_name?: boolean;
|
||||
public zabbix_params: ZabbixParams[] | ZabbixParams
|
||||
|
||||
/**
|
||||
* @param params - The raw parameters to parse.
|
||||
*/
|
||||
constructor(params?: any) {
|
||||
if (Array.isArray(params)) {
|
||||
this.zabbix_params = params.map(arg => this.parseArgObject(arg))
|
||||
|
|
@ -46,6 +53,11 @@ export class ParsedArgs {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a parameter value by name.
|
||||
* @param paramName - The name of the parameter to retrieve.
|
||||
* @returns The parameter value or undefined.
|
||||
*/
|
||||
getParam(paramName: string): any {
|
||||
if (this.zabbix_params instanceof Array) {
|
||||
return undefined
|
||||
|
|
@ -54,6 +66,11 @@ export class ParsedArgs {
|
|||
return paramName in this.zabbix_params ? this.zabbix_params[paramName] : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an argument object into Zabbix parameters.
|
||||
* @param args - The raw argument object.
|
||||
* @returns The parsed Zabbix parameters.
|
||||
*/
|
||||
parseArgObject(args?: any) {
|
||||
if (args && (typeof args !== 'object' || args.constructor !== Object)) {
|
||||
return args;
|
||||
|
|
@ -146,6 +163,9 @@ export class ParsedArgs {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for all Zabbix API requests.
|
||||
*/
|
||||
export class ZabbixRequest<T extends ZabbixResult, A extends ParsedArgs = ParsedArgs> {
|
||||
protected requestBodyTemplate: ZabbixRequestBody;
|
||||
protected method: string
|
||||
|
|
@ -153,11 +173,22 @@ export class ZabbixRequest<T extends ZabbixResult, A extends ParsedArgs = Parsed
|
|||
protected skippableZabbixParams: Map<string, string> = new Map();
|
||||
protected impliedFields: Map<string, string[]> = new Map();
|
||||
|
||||
/**
|
||||
* @param path - The Zabbix API method path.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(public path: string, public authToken?: string | null, public cookie?: string | null) {
|
||||
this.method = path.split(".", 2).join(".");
|
||||
this.requestBodyTemplate = new ZabbixRequestBody(this.method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes Zabbix parameters by removing unused fields and adding implied fields based on the requested output.
|
||||
* @param params - The Zabbix parameters to optimize.
|
||||
* @param output - The list of requested output fields.
|
||||
* @returns The optimized Zabbix parameters.
|
||||
*/
|
||||
optimizeZabbixParams(params: ZabbixParams, output?: string[]): ZabbixParams {
|
||||
if (!output || output.length === 0) {
|
||||
return params;
|
||||
|
|
@ -202,10 +233,24 @@ export class ZabbixRequest<T extends ZabbixResult, A extends ParsedArgs = Parsed
|
|||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the parameters for the Zabbix API request.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param output - The list of fields to return.
|
||||
* @returns The Zabbix parameters.
|
||||
*/
|
||||
createZabbixParams(args?: A, output?: string[]): ZabbixParams {
|
||||
return this.optimizeZabbixParams(args?.zabbix_params || {}, output)
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the request body for the Zabbix API call.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param zabbixParams - Optional pre-constructed Zabbix parameters.
|
||||
* @param output - The list of fields to return.
|
||||
* @param version - The Zabbix API version.
|
||||
* @returns The constructed Zabbix request body.
|
||||
*/
|
||||
getRequestBody(args?: A, zabbixParams?: ZabbixParams, output?: string[], version?: string): ZabbixRequestBody {
|
||||
let params: ZabbixParams
|
||||
if (Array.isArray(args?.zabbix_params)) {
|
||||
|
|
@ -233,6 +278,10 @@ export class ZabbixRequest<T extends ZabbixResult, A extends ParsedArgs = Parsed
|
|||
return body
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the HTTP headers for the Zabbix API call.
|
||||
* @returns The HTTP headers.
|
||||
*/
|
||||
headers() {
|
||||
let headers: {
|
||||
"Content-Type": string
|
||||
|
|
@ -255,12 +304,25 @@ export class ZabbixRequest<T extends ZabbixResult, A extends ParsedArgs = Parsed
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepares the request before execution. Can be overridden to perform checks or transformations.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @param _args - The parsed arguments for the request.
|
||||
* @returns A promise that resolves to the result, an error, or undefined if preparation is successful.
|
||||
*/
|
||||
async prepare(zabbixAPI: ZabbixAPI, _args?: A): Promise<T | ZabbixErrorResult | undefined> {
|
||||
// If prepare returns something else than undefined, the execution will be skipped and the
|
||||
// result returned
|
||||
return this.prepResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns the result or an error.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param output - The list of fields to return.
|
||||
* @returns A promise that resolves to the result or an error.
|
||||
*/
|
||||
async executeRequestReturnError(zabbixAPI: ZabbixAPI, args?: A, output?: string[]): Promise<T | ZabbixErrorResult> {
|
||||
let prepareResult = await this.prepare(zabbixAPI, args);
|
||||
if (prepareResult) {
|
||||
|
|
@ -299,6 +361,14 @@ export class ZabbixRequest<T extends ZabbixResult, A extends ParsedArgs = Parsed
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and throws an error if it fails.
|
||||
* @param zabbixApi - The Zabbix API instance.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param output - The list of fields to return.
|
||||
* @returns A promise that resolves to the result.
|
||||
* @throws GraphQLError if the request fails.
|
||||
*/
|
||||
async executeRequestThrowError(zabbixApi: ZabbixAPI, args?: A, output?: string[]): Promise<T> {
|
||||
let response = await this.executeRequestReturnError(zabbixApi, args, output);
|
||||
if (isZabbixErrorResult(response)) {
|
||||
|
|
@ -317,16 +387,34 @@ export class ZabbixRequest<T extends ZabbixResult, A extends ParsedArgs = Parsed
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for creating or updating entities in Zabbix.
|
||||
*/
|
||||
export class ZabbixCreateOrUpdateParams extends ParsedArgs {
|
||||
/**
|
||||
* @param args - The raw arguments.
|
||||
* @param dryRun - Whether to perform a dry run (default: true).
|
||||
*/
|
||||
constructor(args: any, public dryRun = true) {
|
||||
super(args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to create or update entities in Zabbix.
|
||||
* Automatically checks if an entity with the same name already exists.
|
||||
*/
|
||||
export class ZabbixCreateOrUpdateRequest<
|
||||
T extends ZabbixResult,
|
||||
P extends ZabbixRequest<ZabbixResult>,
|
||||
A extends ZabbixCreateOrUpdateParams = ZabbixCreateOrUpdateParams> extends ZabbixRequest<T, A> {
|
||||
/**
|
||||
* @param entity - The entity name (e.g., "host", "usergroup").
|
||||
* @param updateExistingIdFieldname - The name of the ID field used for updating.
|
||||
* @param prepareType - The class type used to query for existing entities.
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(public entity: string,
|
||||
public updateExistingIdFieldname: string,
|
||||
private prepareType: new (authToken?: string | null, cookie?: string | null) => P, authToken?: string | null, cookie?: string | null) {
|
||||
|
|
|
|||
|
|
@ -3,12 +3,21 @@ import {ApiErrorCode} from "../model/model_enum_values.js";
|
|||
import {isZabbixErrorResult, ParsedArgs, ZabbixErrorResult, ZabbixParams, ZabbixRequest} from "./zabbix-request.js";
|
||||
import {ZabbixQueryHostsMetaRequest} from "./zabbix-hosts.js";
|
||||
|
||||
/**
|
||||
* Parameters for forcing a Zabbix configuration cache reload.
|
||||
*/
|
||||
export class ZabbixForceCacheReloadParams extends ParsedArgs {
|
||||
/**
|
||||
* @param hostid - The ID of the host to execute the script on.
|
||||
*/
|
||||
constructor(public hostid: number) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to force a Zabbix configuration cache reload.
|
||||
*/
|
||||
export class ZabbixForceCacheReloadRequest extends ZabbixRequest<{
|
||||
response: string
|
||||
value: string
|
||||
|
|
@ -27,6 +36,10 @@ export class ZabbixForceCacheReloadRequest extends ZabbixRequest<{
|
|||
"scope": "2"
|
||||
};
|
||||
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("script.execute", authToken, cookie);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,25 @@ export interface ZabbixQueryTemplateResponse {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request to query templates from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryTemplatesRequest extends ZabbixRequest<ZabbixQueryTemplateResponse[]> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null,) {
|
||||
super("template.get", authToken, cookie);
|
||||
this.skippableZabbixParams.set("selectItems", "items");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the parameters for the Zabbix API request.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param output - The list of fields to return.
|
||||
* @returns The Zabbix parameters.
|
||||
*/
|
||||
createZabbixParams(args?: ParsedArgs, output?: string[]): ZabbixParams {
|
||||
return this.optimizeZabbixParams({
|
||||
"selectItems": "extend",
|
||||
|
|
@ -26,6 +39,13 @@ export class ZabbixQueryTemplatesRequest extends ZabbixRequest<ZabbixQueryTempla
|
|||
}, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns the result or an error.
|
||||
* @param zabbixAPI - The Zabbix API instance.
|
||||
* @param args - The parsed arguments for the request.
|
||||
* @param output - The list of fields to return.
|
||||
* @returns A promise that resolves to the result or an error.
|
||||
*/
|
||||
async executeRequestReturnError(zabbixAPI: ZabbixAPI, args?: ParsedArgs, output?: string[]): Promise<ZabbixErrorResult | ZabbixQueryTemplateResponse[]> {
|
||||
let result = await super.executeRequestReturnError(zabbixAPI, args, output);
|
||||
|
||||
|
|
@ -64,44 +84,93 @@ export interface ZabbixQueryTemplateGroupResponse {
|
|||
uuid: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to query template groups from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryTemplateGroupRequest extends ZabbixRequest<ZabbixQueryTemplateGroupResponse[]> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("templategroup.get", authToken, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request to create a template group in Zabbix.
|
||||
*/
|
||||
export class ZabbixCreateTemplateGroupRequest extends ZabbixRequest<{ groupids: string[] }> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("templategroup.create", authToken, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to create a template in Zabbix.
|
||||
*/
|
||||
export class ZabbixCreateTemplateRequest extends ZabbixRequest<{ templateids: string[] }> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("template.create", authToken, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to query items from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryItemRequest extends ZabbixRequest<any[]> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("item.get", authToken, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to create an item in Zabbix.
|
||||
*/
|
||||
export class ZabbixCreateItemRequest extends ZabbixRequest<{ itemids: string[] }> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("item.create", authToken, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to delete templates in Zabbix.
|
||||
*/
|
||||
export class ZabbixDeleteTemplatesRequest extends ZabbixRequest<{ templateids: string[] }> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("template.delete", authToken, cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to delete template groups in Zabbix.
|
||||
*/
|
||||
export class ZabbixDeleteTemplateGroupsRequest extends ZabbixRequest<{ groupids: string[] }> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("templategroup.delete", authToken, cookie);
|
||||
}
|
||||
|
|
@ -109,6 +178,14 @@ export class ZabbixDeleteTemplateGroupsRequest extends ZabbixRequest<{ groupids:
|
|||
|
||||
|
||||
export class TemplateHelper {
|
||||
/**
|
||||
* Finds template IDs by their names.
|
||||
* @param templateNames - The names of the templates to find.
|
||||
* @param zabbixApi - The Zabbix API instance.
|
||||
* @param zabbixAuthToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
* @returns A promise that resolves to an array of template IDs or null if any template is not found.
|
||||
*/
|
||||
public static async findTemplateIdsByName(templateNames: string[], zabbixApi: ZabbixAPI, zabbixAuthToken?: string, cookie?: string) {
|
||||
let result: number[] = []
|
||||
for (let templateName of templateNames) {
|
||||
|
|
|
|||
|
|
@ -56,9 +56,16 @@ abstract class ZabbixPrepareGetTemplatesAndHostgroupsRequest<T extends ZabbixRes
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for exporting user groups.
|
||||
*/
|
||||
export class ZabbixExportUserGroupArgs extends ParsedArgs {
|
||||
public exclude_hostgroups_pattern?: RegExp | undefined = undefined;
|
||||
|
||||
/**
|
||||
* @param name_pattern - Optional wildcard name pattern for filtering user groups.
|
||||
* @param exclude_hostgroups_pattern_str - Optional regex string to exclude host groups by name.
|
||||
*/
|
||||
constructor(name_pattern?: string | null, exclude_hostgroups_pattern_str?: string | null) {
|
||||
super(name_pattern? {name_pattern: name_pattern} : undefined);
|
||||
if (exclude_hostgroups_pattern_str) {
|
||||
|
|
@ -67,8 +74,15 @@ export class ZabbixExportUserGroupArgs extends ParsedArgs {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to export user groups from Zabbix.
|
||||
*/
|
||||
export class ZabbixExportUserGroupsRequest extends ZabbixPrepareGetTemplatesAndHostgroupsRequest<
|
||||
UserGroup[], ZabbixExportUserGroupArgs> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string) {
|
||||
super("usergroup.get.withuuids", authToken, cookie);
|
||||
}
|
||||
|
|
@ -117,7 +131,14 @@ export class ZabbixExportUserGroupsRequest extends ZabbixPrepareGetTemplatesAndH
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to query user groups from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryUserGroupsRequest extends ZabbixRequest<UserGroup[]> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("usergroup.get", authToken, cookie);
|
||||
}
|
||||
|
|
@ -130,15 +151,29 @@ export class ZabbixQueryUserGroupsRequest extends ZabbixRequest<UserGroup[]> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for importing user groups.
|
||||
*/
|
||||
export class ZabbixImportUserGroupsParams extends ParsedArgs {
|
||||
/**
|
||||
* @param usergroups - The user groups to import.
|
||||
* @param dryRun - Whether to perform a dry run (default: true).
|
||||
*/
|
||||
constructor(public usergroups: UserGroupInput[], public dryRun = true) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to import user groups into Zabbix.
|
||||
*/
|
||||
export class ZabbixImportUserGroupsRequest
|
||||
extends ZabbixPrepareGetTemplatesAndHostgroupsRequest<ImportUserRightResult[],
|
||||
ZabbixImportUserGroupsParams> {
|
||||
/**
|
||||
* @param zabbixAuthToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(zabbixAuthToken: any, cookie: any) {
|
||||
super("usergroup.create.import", zabbixAuthToken, cookie);
|
||||
}
|
||||
|
|
@ -328,8 +363,15 @@ class ZabbixPropagateHostGroupsParams extends ParsedArgs {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to propagate host group permissions to children in Zabbix.
|
||||
*/
|
||||
export class ZabbixPropagateHostGroupsRequest extends ZabbixRequest<ZabbixCreateUserGroupResponse,
|
||||
ZabbixPropagateHostGroupsParams> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("hostgroup.propagate", authToken, cookie);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,14 @@ export class ZabbixPrepareGetModulesRequest<T extends ZabbixResult, A extends Pa
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to query user roles from Zabbix.
|
||||
*/
|
||||
export class ZabbixQueryUserRolesRequest extends ZabbixPrepareGetModulesRequest<UserRole[]> {
|
||||
/**
|
||||
* @param authToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(authToken?: string | null, cookie?: string | null) {
|
||||
super("role.get", authToken, cookie);
|
||||
}
|
||||
|
|
@ -63,14 +70,28 @@ export class ZabbixQueryUserRolesRequest extends ZabbixPrepareGetModulesRequest<
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for importing user roles.
|
||||
*/
|
||||
export class ZabbixImportUserRolesParams extends ParsedArgs {
|
||||
/**
|
||||
* @param userRoles - The user roles to import.
|
||||
* @param dryRun - Whether to perform a dry run (default: false).
|
||||
*/
|
||||
constructor(public userRoles: UserRoleInput[], public dryRun: boolean = false) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to import user roles into Zabbix.
|
||||
*/
|
||||
export class ZabbixImportUserRolesRequest extends ZabbixPrepareGetModulesRequest<ImportUserRightResult[],
|
||||
ZabbixImportUserRolesParams> {
|
||||
/**
|
||||
* @param zabbixAuthToken - Optional Zabbix authentication token.
|
||||
* @param cookie - Optional session cookie.
|
||||
*/
|
||||
constructor(zabbixAuthToken: any, cookie: any) {
|
||||
super("role.create.import", zabbixAuthToken, cookie);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue