This commit is contained in:
2025-11-18 20:47:48 +00:00
commit 747fb787e1
38 changed files with 18518 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
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<IIxFac[]> {
return this.client.request<IIxFac>('ixfac', 'GET', options);
}
/**
* Get a single IX-facility connection by ID
*/
async getById(id: number, depth?: 0 | 1 | 2): Promise<IIxFac | null> {
const options: IQueryOptions = { id };
if (depth !== undefined) {
options.depth = depth;
}
const results = await this.client.request<IIxFac>('ixfac', 'GET', options);
return results[0] || null;
}
/**
* Get IX-facility connections by exchange ID
*/
async getByIxId(ixId: number, options: IQueryOptions = {}): Promise<IIxFac[]> {
return this.client.request<IIxFac>('ixfac', 'GET', {
...options,
ix_id: ixId,
});
}
/**
* Get IX-facility connections by facility ID
*/
async getByFacId(facId: number, options: IQueryOptions = {}): Promise<IIxFac[]> {
return this.client.request<IIxFac>('ixfac', 'GET', {
...options,
fac_id: facId,
});
}
/**
* Create a new IX-facility connection (requires authentication)
*/
async create(data: Partial<IIxFac>): Promise<IIxFac> {
const results = await this.client.request<IIxFac>('ixfac', 'POST', {}, data);
return results[0];
}
/**
* Update an IX-facility connection (requires authentication)
*/
async update(id: number, data: Partial<IIxFac>): Promise<IIxFac> {
const results = await this.client.request<IIxFac>(`ixfac/${id}`, 'PUT', {}, data);
return results[0];
}
/**
* Delete an IX-facility connection (requires authentication)
*/
async delete(id: number): Promise<void> {
await this.client.request('ixfac', 'DELETE', { id });
}
}