import {LegacyOpenFlareBaseService} from './legacy-base.service'; import type { NodeAgentReleaseInfo, NodeAgentUpdatePayload, NodeBootstrapToken, NodeItem, NodeMutationPayload, NodeObservability, ReleaseChannel, } from './types'; export class NodeService extends LegacyOpenFlareBaseService { protected static readonly basePath = '/api/nodes'; static async listNodes(): Promise { return this.legacyGet('/'); } static async createNode(payload: NodeMutationPayload): Promise { return this.legacyPost('/', payload); } static async updateNode(id: number, payload: NodeMutationPayload): Promise { return this.legacyPost(`/${id}/update`, payload); } static async deleteNode(id: number): Promise { return this.legacyPost(`/${id}/delete`); } static async getBootstrapToken(): Promise { return this.legacyGet('/bootstrap-token'); } static async rotateBootstrapToken(): Promise { return this.legacyPost('/bootstrap-token/rotate'); } static async requestAgentUpdate( id: number, payload?: NodeAgentUpdatePayload, ): Promise { return this.legacyPost(`/${id}/agent-update`, payload ?? {}); } static async requestForceSync(id: number): Promise { return this.legacyPost(`/${id}/force-sync`); } static async requestOpenrestyRestart(id: number): Promise { return this.legacyPost(`/${id}/openresty-restart`); } static async getAgentRelease( id: number, channel: ReleaseChannel = 'stable', ): Promise { return this.legacyGet(`/${id}/agent-release`, { channel }); } static async getObservability( id: number, options?: { hours?: number; limit?: number }, ): Promise { return this.legacyGet(`/${id}/observability`, { hours: options?.hours, limit: options?.limit, }); } static async cleanupHealthEvents( id: number, ): Promise<{ node_id: string; deleted_count: number }> { return this.legacyPost<{ node_id: string; deleted_count: number }>( `/${id}/observability/cleanup`, ); } }