initial
This commit is contained in:
72
ts/peeringdb.classes.ixpfxmanager.ts
Normal file
72
ts/peeringdb.classes.ixpfxmanager.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import type { PeeringDbClient } from './peeringdb.classes.client.js';
|
||||
import type { IIxPfx } from './interfaces/peeringdb.api.ixpfx.js';
|
||||
import type { IQueryOptions } from './peeringdb.types.js';
|
||||
|
||||
/**
|
||||
* Manager for IxPfx resources (IX IP prefixes)
|
||||
*/
|
||||
export class IxPfxManager {
|
||||
constructor(private client: PeeringDbClient) {}
|
||||
|
||||
/**
|
||||
* List IX prefixes with optional filtering
|
||||
*/
|
||||
async list(options: IQueryOptions = {}): Promise<IIxPfx[]> {
|
||||
return this.client.request<IIxPfx>('ixpfx', 'GET', options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single IX prefix by ID
|
||||
*/
|
||||
async getById(id: number, depth?: 0 | 1 | 2): Promise<IIxPfx | null> {
|
||||
const options: IQueryOptions = { id };
|
||||
if (depth !== undefined) {
|
||||
options.depth = depth;
|
||||
}
|
||||
const results = await this.client.request<IIxPfx>('ixpfx', 'GET', options);
|
||||
return results[0] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IX prefixes by IX LAN ID
|
||||
*/
|
||||
async getByIxLanId(ixlanId: number, options: IQueryOptions = {}): Promise<IIxPfx[]> {
|
||||
return this.client.request<IIxPfx>('ixpfx', 'GET', {
|
||||
...options,
|
||||
ixlan_id: ixlanId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IX prefixes by protocol (IPv4/IPv6)
|
||||
*/
|
||||
async getByProtocol(protocol: string, options: IQueryOptions = {}): Promise<IIxPfx[]> {
|
||||
return this.client.request<IIxPfx>('ixpfx', 'GET', {
|
||||
...options,
|
||||
protocol,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new IX prefix (requires authentication)
|
||||
*/
|
||||
async create(data: Partial<IIxPfx>): Promise<IIxPfx> {
|
||||
const results = await this.client.request<IIxPfx>('ixpfx', 'POST', {}, data);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an IX prefix (requires authentication)
|
||||
*/
|
||||
async update(id: number, data: Partial<IIxPfx>): Promise<IIxPfx> {
|
||||
const results = await this.client.request<IIxPfx>(`ixpfx/${id}`, 'PUT', {}, data);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an IX prefix (requires authentication)
|
||||
*/
|
||||
async delete(id: number): Promise<void> {
|
||||
await this.client.request('ixpfx', 'DELETE', { id });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user