import type { PeeringDbClient } from './peeringdb.classes.client.js'; import type { IIxFac } from './interfaces/peeringdb.api.ixfac.js'; import type { IQueryOptions } from './peeringdb.types.js'; /** * Manager for IxFac resources (IX-facility connections) */ export class IxFacManager { constructor(private client: PeeringDbClient) {} /** * List IX-facility connections with optional filtering */ async list(options: IQueryOptions = {}): Promise { return this.client.request('ixfac', 'GET', options); } /** * Get a single IX-facility connection 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('ixfac', 'GET', options); return results[0] || null; } /** * Get IX-facility connections by exchange ID */ async getByIxId(ixId: number, options: IQueryOptions = {}): Promise { return this.client.request('ixfac', 'GET', { ...options, ix_id: ixId, }); } /** * Get IX-facility connections by facility ID */ async getByFacId(facId: number, options: IQueryOptions = {}): Promise { return this.client.request('ixfac', 'GET', { ...options, fac_id: facId, }); } /** * Create a new IX-facility connection (requires authentication) */ async create(data: Partial): Promise { const results = await this.client.request('ixfac', 'POST', {}, data); return results[0]; } /** * Update an IX-facility connection (requires authentication) */ async update(id: number, data: Partial): Promise { const results = await this.client.request(`ixfac/${id}`, 'PUT', {}, data); return results[0]; } /** * Delete an IX-facility connection (requires authentication) */ async delete(id: number): Promise { await this.client.request('ixfac', 'DELETE', { id }); } }