73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
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 });
|
|
}
|
|
}
|