import type { PeeringDbClient } from './peeringdb.classes.client.js'; import type { IPointOfContact } from './interfaces/peeringdb.api.poc.js'; import type { IQueryOptions } from './peeringdb.types.js'; /** * Manager for Point of Contact resources */ export class PocManager { constructor(private client: PeeringDbClient) {} /** * List points of contact with optional filtering */ async list(options: IQueryOptions = {}): Promise { return this.client.request('poc', 'GET', options); } /** * Get a single point of contact 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('poc', 'GET', options); return results[0] || null; } /** * Get points of contact by network ID */ async getByNetId(netId: number, options: IQueryOptions = {}): Promise { return this.client.request('poc', 'GET', { ...options, net_id: netId, }); } /** * Get points of contact by role */ async getByRole(role: string, options: IQueryOptions = {}): Promise { return this.client.request('poc', 'GET', { ...options, role__contains: role, }); } /** * Create a new point of contact (requires authentication) */ async create(data: Partial): Promise { const results = await this.client.request('poc', 'POST', {}, data); return results[0]; } /** * Update a point of contact (requires authentication) */ async update(id: number, data: Partial): Promise { const results = await this.client.request(`poc/${id}`, 'PUT', {}, data); return results[0]; } /** * Delete a point of contact (requires authentication) */ async delete(id: number): Promise { await this.client.request('poc', 'DELETE', { id }); } }