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