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 { INetFac } from './interfaces/peeringdb.api.netfac.js';
import type { IQueryOptions } from './peeringdb.types.js';
/**
* Manager for NetFac resources (network presence at facility)
*/
export class NetFacManager {
constructor(private client: PeeringDbClient) {}
/**
* List network-facility connections with optional filtering
*/
async list(options: IQueryOptions = {}): Promise<INetFac[]> {
return this.client.request<INetFac>('netfac', 'GET', options);
}
/**
* Get a single network-facility connection by ID
*/
async getById(id: number, depth?: 0 | 1 | 2): Promise<INetFac | null> {
const options: IQueryOptions = { id };
if (depth !== undefined) {
options.depth = depth;
}
const results = await this.client.request<INetFac>('netfac', 'GET', options);
return results[0] || null;
}
/**
* Get network-facility connections by network ID
*/
async getByNetId(netId: number, options: IQueryOptions = {}): Promise<INetFac[]> {
return this.client.request<INetFac>('netfac', 'GET', {
...options,
net_id: netId,
});
}
/**
* Get network-facility connections by facility ID
*/
async getByFacId(facId: number, options: IQueryOptions = {}): Promise<INetFac[]> {
return this.client.request<INetFac>('netfac', 'GET', {
...options,
fac_id: facId,
});
}
/**
* Create a new network-facility connection (requires authentication)
*/
async create(data: Partial<INetFac>): Promise<INetFac> {
const results = await this.client.request<INetFac>('netfac', 'POST', {}, data);
return results[0];
}
/**
* Update a network-facility connection (requires authentication)
*/
async update(id: number, data: Partial<INetFac>): Promise<INetFac> {
const results = await this.client.request<INetFac>(`netfac/${id}`, 'PUT', {}, data);
return results[0];
}
/**
* Delete a network-facility connection (requires authentication)
*/
async delete(id: number): Promise<void> {
await this.client.request('netfac', 'DELETE', { id });
}
}