initial
This commit is contained in:
72
ts/peeringdb.classes.pocmanager.ts
Normal file
72
ts/peeringdb.classes.pocmanager.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import type { PeeringDbClient } from './peeringdb.classes.client.js';
|
||||
import type { IPointOfContact } from './interfaces/peeringdb.api.poc.js';
|
||||
import type { IQueryOptions } from './peeringdb.types.js';
|
||||
|
||||
/**
|
||||
* Manager for Point of Contact resources
|
||||
*/
|
||||
export class PocManager {
|
||||
constructor(private client: PeeringDbClient) {}
|
||||
|
||||
/**
|
||||
* List points of contact with optional filtering
|
||||
*/
|
||||
async list(options: IQueryOptions = {}): Promise<IPointOfContact[]> {
|
||||
return this.client.request<IPointOfContact>('poc', 'GET', options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single point of contact by ID
|
||||
*/
|
||||
async getById(id: number, depth?: 0 | 1 | 2): Promise<IPointOfContact | null> {
|
||||
const options: IQueryOptions = { id };
|
||||
if (depth !== undefined) {
|
||||
options.depth = depth;
|
||||
}
|
||||
const results = await this.client.request<IPointOfContact>('poc', 'GET', options);
|
||||
return results[0] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get points of contact by network ID
|
||||
*/
|
||||
async getByNetId(netId: number, options: IQueryOptions = {}): Promise<IPointOfContact[]> {
|
||||
return this.client.request<IPointOfContact>('poc', 'GET', {
|
||||
...options,
|
||||
net_id: netId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get points of contact by role
|
||||
*/
|
||||
async getByRole(role: string, options: IQueryOptions = {}): Promise<IPointOfContact[]> {
|
||||
return this.client.request<IPointOfContact>('poc', 'GET', {
|
||||
...options,
|
||||
role__contains: role,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new point of contact (requires authentication)
|
||||
*/
|
||||
async create(data: Partial<IPointOfContact>): Promise<IPointOfContact> {
|
||||
const results = await this.client.request<IPointOfContact>('poc', 'POST', {}, data);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a point of contact (requires authentication)
|
||||
*/
|
||||
async update(id: number, data: Partial<IPointOfContact>): Promise<IPointOfContact> {
|
||||
const results = await this.client.request<IPointOfContact>(`poc/${id}`, 'PUT', {}, data);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a point of contact (requires authentication)
|
||||
*/
|
||||
async delete(id: number): Promise<void> {
|
||||
await this.client.request('poc', 'DELETE', { id });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user