import { Connection, type RequestOptions } from './Connection.js'; import type { ConnectionProps } from './ConnectionProps.js'; import type { AdminEmitEvents, AdminListenEvents, CompactAdapterInfo, CompactHost, CompactInstalledInfo, CompactInstanceInfo, CompactRepository, CompactSystemRepository, License, LogFile } from './SocketEvents.js'; interface Certificate { name: string; type: 'public' | 'private' | 'chained'; } export type MultilingualObject = Exclude; export type Severity = 'info' | 'notify' | 'alert'; export interface NotificationMessageObject { message: string; ts: number; } type DockerInformation = { /** If it is a Docker installation */ isDocker: boolean; /** If it is the official Docker image */ isOfficial: true; /** Semver string for official Docker image */ officialVersion: string; } | { /** If it is a Docker installation */ isDocker: boolean; /** If it is the official Docker image */ isOfficial: false; }; export interface HostInfo { /** Converted OS for human readability */ Platform: 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd' | 'docker' | 'Windows' | 'OSX'; /** The underlying OS */ os: 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd'; /** Information about the docker installation */ dockerInformation?: DockerInformation; /** Host architecture */ Architecture: string; /** Number of CPUs */ CPUs: number | null; /** CPU speed */ Speed: number | null; /** CPU model */ Model: string | null; /** Total RAM of host */ RAM: number; /** System uptime in seconds */ 'System uptime': number; /** Node.JS version */ 'Node.js': string; /** Current time to compare to local time */ time: number; /** Timezone offset to compare to local time */ timeOffset: number; /** Number of available adapters */ 'adapters count': number; /** NPM version */ NPM: string; /** Running instances */ 'Active instances': number; /** Location on disk of iobroker folder */ location: string; /** Uptime */ Uptime: number; /** Free disk space */ 'Disk free': number; /** Disk size */ 'Disk size': number; } export interface AdapterInformation { /** this flag is only true for the js-controller */ controller: boolean; /** adapter version */ version: string; /** path to icon of the adapter */ icon: string; /** path to local icon of the adapter */ localIcon?: string; /** title of the adapter */ title: string; /** title of the adapter in multiple languages */ titleLang: ioBroker.Translated; /** description of the adapter in multiple languages */ desc: ioBroker.Translated; /** platform of the adapter */ platform: 'Javascript/Node.js'; /** keywords of the adapter */ keywords: string[]; /** path to a readme file */ readme: string; /** The installed adapter version, not existing on controller */ runningVersion?: string; /** type of the adapter */ type: string; /** license of the adapter */ license: string; /** url to license information */ licenseUrl?: string; } export type AdapterRating = { rating?: { r: number; c: number; }; [version: string]: { r: number; c: number; }; }; export type AdapterRatingInfo = AdapterRating & { title: string; }; export type AdapterInformationEx = AdapterInformation & { installedFrom?: string; enabled: number; count: number; ignoreVersion?: string; }; export type InstalledInfo = { [adapterName: string]: AdapterInformationEx; } & { hosts?: { [hostName: string]: ioBroker.HostCommon & { host: string; runningVersion: string; }; }; }; interface RepositoryEntry { /** Link to external icon */ extIcon: string; /** Translated title */ titleLang: ioBroker.Translated; [other: string]: unknown; } /** The ioBroker repository */ export type Repository = Record; export interface FilteredNotificationInformation { [scope: string]: { description: MultilingualObject; name: MultilingualObject; categories: { [category: string]: { description: MultilingualObject; name: MultilingualObject; severity: Severity; instances: { [instance: string]: { messages: NotificationMessageObject[]; }; }; }; }; }; } export interface IPAddress { name: string; address: string; family: 'ipv4' | 'ipv6'; internal?: boolean; } export declare class AdminConnection extends Connection { constructor(props: ConnectionProps); protected request(options: RequestOptions): Promise; /** * Get the stored certificates. * * @param update Force update. */ getCertificates(update?: boolean): Promise; /** * Get the logs from a host (only for admin connection). */ getLogs(host: string, linesNumber?: number): Promise<(string | number)[] | string | { error: string; }>; /** * Upgrade adapter with webserver. */ upgradeAdapterWithWebserver(host: string, options: { version: string; adapterName: string; port: number; useHttps?: boolean; certPublicName?: string; certPrivateName?: string; }): Promise<{ result: boolean; }>; /** * Upgrade controller */ upgradeController(host: string, version: string, adminInstance: number): Promise; /** * Read licenses from ioBroker.net anew */ updateLicenses( /** login for ioBroker.net */ login: string, /** password for ioBroker.net */ password: string): Promise; /** * Upgrade controller */ upgradeOsPackages(host: string, packages: { name: string; version?: string; }[], restart?: boolean): Promise<{ success: boolean; error?: string; }>; /** * Get the log files (only for admin connection). */ getLogsFiles(host: string): Promise; /** * Delete the logs from a host (only for admin connection). */ delLogs(host: string): Promise; /** * Delete a file of an adapter. * * @param adapter The adapter name. * @param fileName The file name. */ deleteFile(adapter: string, fileName: string): Promise; /** * Delete a folder of an adapter. * * @param adapter The adapter name. * @param folderName The folder name. */ deleteFolder(adapter: string, folderName: string): Promise; /** * Rename file or folder in ioBroker DB * * @param adapter instance name * @param oldName current file name, e.g., main/vis-views.json * @param newName new file name, e.g., main/vis-views-new.json */ rename(adapter: string, oldName: string, newName: string): Promise; /** * Rename file in ioBroker DB * * @param adapter instance name * @param oldName current file name, e.g., main/vis-views.json * @param newName new file name, e.g., main/vis-views-new.json */ renameFile(adapter: string, oldName: string, newName: string): Promise; /** * Get the list of all hosts. * * @param update Force update. */ getHosts(update?: boolean): Promise; /** * Get the list of all users. * * @param update Force update. */ getUsers(update?: boolean): Promise; /** * Rename a group. * * @param id The id. * @param newId The new id. * @param newName The new name. */ renameGroup(id: string, newId: string, newName: ioBroker.StringOrTranslated): Promise; /** * Get the host information. * * @param host host name * @param update Force update. * @param timeoutMs optional read timeout. */ getHostInfo(host: string, update?: boolean, timeoutMs?: number): Promise; /** * Get the host information (short version). * * @param host host name * @param update Force update. * @param timeoutMs optional read timeout. */ getHostInfoShort(host: string, update?: boolean, timeoutMs?: number): Promise; /** * Get the repository. * * @param host The host name. * @param args The arguments. * @param update Force update. * @param timeoutMs timeout in ms. */ getRepository(host: string, args?: { update?: boolean; repo?: string | string[]; } | string | null, update?: boolean, timeoutMs?: number): Promise; /** * Get the installed. * * @param host The host name. * @param update Force update. * @param cmdTimeout timeout in ms */ getInstalled(host: string, update?: boolean, cmdTimeout?: number): Promise; /** * Execute a command on a host. */ cmdExec( /** The host name. */ host: string, /** The command to execute. */ cmd: string, /** The command ID. */ cmdId: number, /** Timeout of command in ms */ cmdTimeout?: number): Promise; /** * Read the base settings of a given host. * * @param host The host name. */ readBaseSettings(host: string): Promise<{ config?: ioBroker.IoBrokerJson; isActive?: boolean; }>; /** * Write the base settings of a given host. * * @param host The host name. * @param config The configuration to write. */ writeBaseSettings(host: string, config: ioBroker.IoBrokerJson): Promise<{ error?: string; result?: 'ok'; }>; /** * Send command to restart the iobroker on host * * @param host The host name. */ restartController(host: string): Promise; /** * Read statistics information from host * * @param host The host name. * @param typeOfDiag one of none, normal, no-city, extended */ getDiagData(host: string, typeOfDiag: 'none' | 'normal' | 'no-city' | 'extended'): Promise | null>; /** * Change the password of the given user. * * @param user The user name. * @param password The new password. */ changePassword(user: string, password: string): Promise; /** * Get the IP addresses of the given host. * * @param host The host name. * @param update Force update. */ getIpAddresses(host: string, update?: boolean): Promise; /** * Get the IP addresses with interface names of the given host or find host by IP. * * @param ipOrHostName The IP address or host name. * @param update Force update. */ getHostByIp(ipOrHostName: string, update?: boolean): Promise; /** * Encrypt a text * * @param plaintext The text to encrypt. */ encrypt(plaintext: string): Promise; /** * Decrypt a text * * @param ciphertext The text to decrypt. */ decrypt(ciphertext: string): Promise; /** * Change access rights for file * * @param adapter adapter name * @param path file name with a full path. It could be like 'vis.0/*' * @param options like {mode: 0x644} * @param options.mode The new mode for the file */ chmodFile(adapter: string | null, path: string, options?: { mode: number | string; }): Promise; /** * Change an owner or/and owner group for file * * @param adapter adapter name * @param filename file name with a full path. it could be like vis.0/* * @param options like {owner: "newOwner", ownerGroup: "newGroup"} * @param options.owner The new owner for the file * @param options.ownerGroup The new owner group for the file */ chownFile(adapter: string, filename: string, options?: { owner?: string; ownerGroup?: string; }): Promise; /** * Get the alarm notifications from a host (only for admin connection). * * @param host The host name. * @param category - optional */ getNotifications(host: string, category?: string): Promise; /** * Clear the alarm notifications on a host (only for admin connection). * * @param host The host name. * @param category - optional */ clearNotifications(host: string, category: string): Promise<{ result: 'ok'; }>; /** * Read if only easy mode is allowed (only for admin connection). */ getIsEasyModeStrict(): Promise; /** * Read easy mode configuration (only for admin connection). */ getEasyMode(): Promise<{ strict: boolean; configs: { id: string; title: ioBroker.StringOrTranslated; desc: ioBroker.StringOrTranslated; color: string; url: string; icon: string; materialize: boolean; jsonConfig: boolean; version: string; }[]; }>; /** * Read adapter ratings */ getRatings(update?: boolean): Promise<{ [adapterName: string]: AdapterRating; } & { uuid: string; }>; getCurrentSession(cmdTimeout?: number): Promise<{ expireInSec?: number; error?: string; }>; /** * Read current web, socketio or admin namespace, like admin.0 */ getCurrentInstance(): Promise; /** * Get all instances of the given adapter or get all instances. * * @param adapter The name of the adapter. * @param update Force update. */ getAdapterInstances(adapter?: string | boolean, update?: boolean): Promise; /** * Get adapters with the given name or get all adapters. * * @param adapter The name of the adapter. * @param update Force update. */ getAdapters(adapter?: string | boolean, update?: boolean): Promise; getCompactAdapters(update?: boolean): Promise>; getAdaptersResetCache(adapter?: string): void; getCompactInstances(update?: boolean): Promise>; getAdapterInstancesResetCache(adapter?: string): void; getCompactInstalled(host: string, update?: boolean, cmdTimeout?: number): Promise; getInstalledResetCache(host?: string): void; /** * Get the repository in compact form (only version and icon). * * @param host The host name. * @param update Force update. * @param timeoutMs timeout in ms. */ getCompactRepository(host: string, update?: boolean, timeoutMs?: number): Promise; getRepositoryResetCache(host: string): void; /** * Get the list of all hosts in compact form (only _id, common.name, common.icon, common.color, native.hardware.networkInterfaces) * * @param update Force update. */ getCompactHosts(update?: boolean): Promise; /** * Get `system.repository` without big JSON */ getCompactSystemRepositories(update?: boolean): Promise; } export {};