import type { PeeringDbClient } from './peeringdb.classes.client.js'; import type { IIxPfx } from './interfaces/peeringdb.api.ixpfx.js'; import type { IQueryOptions } from './peeringdb.types.js'; /** * Manager for IxPfx resources (IX IP prefixes) */ export class IxPfxManager { constructor(private client: PeeringDbClient) {} /** * List IX prefixes with optional filtering */ async list(options: IQueryOptions = {}): Promise { return this.client.request('ixpfx', 'GET', options); } /** * Get a single IX prefix by ID */ async getById(id: number, depth?: 0 | 1 | 2): Promise { const options: IQueryOptions = { id }; if (depth !== undefined) { options.depth = depth; } const results = await this.client.request('ixpfx', 'GET', options); return results[0] || null; } /** * Get IX prefixes by IX LAN ID */ async getByIxLanId(ixlanId: number, options: IQueryOptions = {}): Promise { return this.client.request('ixpfx', 'GET', { ...options, ixlan_id: ixlanId, }); } /** * Get IX prefixes by protocol (IPv4/IPv6) */ async getByProtocol(protocol: string, options: IQueryOptions = {}): Promise { return this.client.request('ixpfx', 'GET', { ...options, protocol, }); } /** * Create a new IX prefix (requires authentication) */ async create(data: Partial): Promise { const results = await this.client.request('ixpfx', 'POST', {}, data); return results[0]; } /** * Update an IX prefix (requires authentication) */ async update(id: number, data: Partial): Promise { const results = await this.client.request(`ixpfx/${id}`, 'PUT', {}, data); return results[0]; } /** * Delete an IX prefix (requires authentication) */ async delete(id: number): Promise { await this.client.request('ixpfx', 'DELETE', { id }); } }