bunactyl
Version:
TypeScript SDK for Pterodactyl
88 lines (87 loc) • 2.33 kB
JavaScript
import { BunactylClient } from '../client';
export class ServersResource {
constructor(client) {
this.client = client;
}
/**
* List all servers
*
* @param include Optional resources to include
*/
async list(include) {
const params = {};
if (include) {
params['include'] = include;
}
return await this.client.get('/servers', { params });
}
/**
* Get details for a specific server by ID
*
* @param id Server ID
* @param include Optional resources to include
*/
async getById(id, include) {
const params = {};
if (include) {
params['include'] = include;
}
return await this.client.get(`/servers/${id}`, { params });
}
/**
* Get details for a specific server by external ID
*
* @param externalId External server ID
* @param include Optional resources to include
*/
async getByExternalId(externalId, include) {
const params = {};
if (include) {
params['include'] = include;
}
return await this.client.get(`/servers/external/${externalId}`, { params });
}
/**
* Create a new server
*
* @param serverData Server data
*/
async create(serverData) {
return await this.client.post('/servers', serverData);
}
/**
* Update server details
*
* @param id Server ID
* @param details Server details
*/
async updateDetails(id, details) {
return await this.client.patch(`/servers/${id}/details`, details);
}
/**
* Update server build configuration
*
* @param id Server ID
* @param buildConfig Server build configuration
*/
async updateBuild(id, buildConfig) {
return await this.client.patch(`/servers/${id}/build`, buildConfig);
}
/**
* Update server startup configuration
*
* @param id Server ID
* @param startupConfig Server startup configuration
*/
async updateStartup(id, startupConfig) {
return await this.client.patch(`/servers/${id}/startup`, startupConfig);
}
/**
* Delete a server
*
* @param id Server ID
*/
async delete(id) {
await this.client.delete(`/servers/${id}`);
}
}