83 lines
2.3 KiB
TypeScript
83 lines
2.3 KiB
TypeScript
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<INetIxLan[]> {
|
|
return this.client.request<INetIxLan>('netixlan', 'GET', options);
|
|
}
|
|
|
|
/**
|
|
* Get a single network-IX connection by ID
|
|
*/
|
|
async getById(id: number, depth?: 0 | 1 | 2): Promise<INetIxLan | null> {
|
|
const options: IQueryOptions = { id };
|
|
if (depth !== undefined) {
|
|
options.depth = depth;
|
|
}
|
|
const results = await this.client.request<INetIxLan>('netixlan', 'GET', options);
|
|
return results[0] || null;
|
|
}
|
|
|
|
/**
|
|
* Get network-IX connections by network ID
|
|
*/
|
|
async getByNetId(netId: number, options: IQueryOptions = {}): Promise<INetIxLan[]> {
|
|
return this.client.request<INetIxLan>('netixlan', 'GET', {
|
|
...options,
|
|
net_id: netId,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get network-IX connections by IX LAN ID
|
|
*/
|
|
async getByIxLanId(ixlanId: number, options: IQueryOptions = {}): Promise<INetIxLan[]> {
|
|
return this.client.request<INetIxLan>('netixlan', 'GET', {
|
|
...options,
|
|
ixlan_id: ixlanId,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get network-IX connections by ASN
|
|
*/
|
|
async getByAsn(asn: number, options: IQueryOptions = {}): Promise<INetIxLan[]> {
|
|
return this.client.request<INetIxLan>('netixlan', 'GET', {
|
|
...options,
|
|
asn,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Create a new network-IX connection (requires authentication)
|
|
*/
|
|
async create(data: Partial<INetIxLan>): Promise<INetIxLan> {
|
|
const results = await this.client.request<INetIxLan>('netixlan', 'POST', {}, data);
|
|
return results[0];
|
|
}
|
|
|
|
/**
|
|
* Update a network-IX connection (requires authentication)
|
|
*/
|
|
async update(id: number, data: Partial<INetIxLan>): Promise<INetIxLan> {
|
|
const results = await this.client.request<INetIxLan>(`netixlan/${id}`, 'PUT', {}, data);
|
|
return results[0];
|
|
}
|
|
|
|
/**
|
|
* Delete a network-IX connection (requires authentication)
|
|
*/
|
|
async delete(id: number): Promise<void> {
|
|
await this.client.request('netixlan', 'DELETE', { id });
|
|
}
|
|
}
|