initial
This commit is contained in:
62
ts/peeringdb.classes.ixlanmanager.ts
Normal file
62
ts/peeringdb.classes.ixlanmanager.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import type { PeeringDbClient } from './peeringdb.classes.client.js';
|
||||
import type { IIxLan } from './interfaces/peeringdb.api.ixlan.js';
|
||||
import type { IQueryOptions } from './peeringdb.types.js';
|
||||
|
||||
/**
|
||||
* Manager for IxLan resources (IX LAN information)
|
||||
*/
|
||||
export class IxLanManager {
|
||||
constructor(private client: PeeringDbClient) {}
|
||||
|
||||
/**
|
||||
* List IX LANs with optional filtering
|
||||
*/
|
||||
async list(options: IQueryOptions = {}): Promise<IIxLan[]> {
|
||||
return this.client.request<IIxLan>('ixlan', 'GET', options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single IX LAN by ID
|
||||
*/
|
||||
async getById(id: number, depth?: 0 | 1 | 2): Promise<IIxLan | null> {
|
||||
const options: IQueryOptions = { id };
|
||||
if (depth !== undefined) {
|
||||
options.depth = depth;
|
||||
}
|
||||
const results = await this.client.request<IIxLan>('ixlan', 'GET', options);
|
||||
return results[0] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get IX LANs by exchange ID
|
||||
*/
|
||||
async getByIxId(ixId: number, options: IQueryOptions = {}): Promise<IIxLan[]> {
|
||||
return this.client.request<IIxLan>('ixlan', 'GET', {
|
||||
...options,
|
||||
ix_id: ixId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new IX LAN (requires authentication)
|
||||
*/
|
||||
async create(data: Partial<IIxLan>): Promise<IIxLan> {
|
||||
const results = await this.client.request<IIxLan>('ixlan', 'POST', {}, data);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an IX LAN (requires authentication)
|
||||
*/
|
||||
async update(id: number, data: Partial<IIxLan>): Promise<IIxLan> {
|
||||
const results = await this.client.request<IIxLan>(`ixlan/${id}`, 'PUT', {}, data);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an IX LAN (requires authentication)
|
||||
*/
|
||||
async delete(id: number): Promise<void> {
|
||||
await this.client.request('ixlan', 'DELETE', { id });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user