import type { PeeringDbClient } from './peeringdb.classes.client.js'; import type { INetIxLan } from './interfaces/peeringdb.api.netixlan.js'; import type { IQueryOptions } from './peeringdb.types.js'; /** * Manager for NetIxLan resources (network presence at IX) */ export class NetIxLanManager { constructor(private client: PeeringDbClient) {} /** * List network-IX connections with optional filtering */ async list(options: IQueryOptions = {}): Promise { return this.client.request('netixlan', 'GET', options); } /** * Get a single network-IX 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('netixlan', 'GET', options); return results[0] || null; } /** * Get network-IX connections by network ID */ async getByNetId(netId: number, options: IQueryOptions = {}): Promise { return this.client.request('netixlan', 'GET', { ...options, net_id: netId, }); } /** * Get network-IX connections by IX LAN ID */ async getByIxLanId(ixlanId: number, options: IQueryOptions = {}): Promise { return this.client.request('netixlan', 'GET', { ...options, ixlan_id: ixlanId, }); } /** * Get network-IX connections by ASN */ async getByAsn(asn: number, options: IQueryOptions = {}): Promise { return this.client.request('netixlan', 'GET', { ...options, asn, }); } /** * Create a new network-IX connection (requires authentication) */ async create(data: Partial): Promise { const results = await this.client.request('netixlan', 'POST', {}, data); return results[0]; } /** * Update a network-IX connection (requires authentication) */ async update(id: number, data: Partial): Promise { const results = await this.client.request(`netixlan/${id}`, 'PUT', {}, data); return results[0]; } /** * Delete a network-IX connection (requires authentication) */ async delete(id: number): Promise { await this.client.request('netixlan', 'DELETE', { id }); } }