it works
This commit is contained in:
4
.idea/.idea.Pterodactyl.NETSDK/.idea/vcs.xml
generated
4
.idea/.idea.Pterodactyl.NETSDK/.idea/vcs.xml
generated
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
312
Pterodactyl.NETSDK/Application.cs
Normal file
312
Pterodactyl.NETSDK/Application.cs
Normal file
@@ -0,0 +1,312 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Web;
|
||||
using Pterodactyl.NETSDK.Helper;
|
||||
using Pterodactyl.NETSDK.Models.Application.Locations;
|
||||
using Pterodactyl.NETSDK.Models.Application.Nests;
|
||||
using Pterodactyl.NETSDK.Models.Application.Nests.Eggs;
|
||||
using Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
using Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
using Pterodactyl.NETSDK.Models.Application.Users;
|
||||
using Pterodactyl.NETSDK.Models.Common;
|
||||
using Pterodactyl.NETSDK.Models.Common.Allocations;
|
||||
using Pterodactyl.NETSDK.Request;
|
||||
|
||||
namespace Pterodactyl.NETSDK;
|
||||
|
||||
public class Application(string baseUrl, string apiKey) : PterodactylClient(baseUrl, apiKey)
|
||||
{
|
||||
#region Application API
|
||||
|
||||
#region Users
|
||||
|
||||
public async Task<List<User?>> ListUsers()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/users");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<UserResponse>>(response);
|
||||
return result?.Data.Select(r => r.User).ToList() ?? [];
|
||||
}
|
||||
|
||||
public async Task<User?> GetUser(int userId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/users/{userId}");
|
||||
var result = await HttpHelper.HandleResponse<UserResponse>(response);
|
||||
return result?.User;
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByExternalId(string externalId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/users/external/{externalId}");
|
||||
var result = await HttpHelper.HandleResponse<UserResponse>(response);
|
||||
return result?.User;
|
||||
}
|
||||
|
||||
public async Task<User?> CreateUser(UserCreateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/application/users", content);
|
||||
var result = await HttpHelper.HandleResponse<UserResponse>(response);
|
||||
return result?.User;
|
||||
}
|
||||
|
||||
public async Task<User?> UpdateUser(int userId, Action<UserUpdateRequest> updateAction)
|
||||
{
|
||||
var currentUser = await GetUser(userId);
|
||||
|
||||
var request = new UserUpdateRequest
|
||||
{
|
||||
Email = currentUser?.Email,
|
||||
Username = currentUser?.Username,
|
||||
FirstName = currentUser?.FirstName,
|
||||
LastName = currentUser?.LastName,
|
||||
Language = currentUser?.Language
|
||||
};
|
||||
|
||||
updateAction(request);
|
||||
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PatchAsync($"{BaseUrl}/api/application/users/{userId}", content);
|
||||
var result = await HttpHelper.HandleResponse<UserResponse>(response);
|
||||
return result?.User;
|
||||
}
|
||||
|
||||
public async Task DeleteUser(int userId)
|
||||
{
|
||||
var response = await HttpClient.DeleteAsync($"{BaseUrl}/api/application/users/{userId}");
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nodes
|
||||
|
||||
public async Task<List<Node>?> ListNodes()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nodes");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<NodeResponse>>(response);
|
||||
|
||||
return result?.Data.Select(n => n.Node).ToList() ?? [];
|
||||
}
|
||||
|
||||
public async Task<Node?> GetNode(int nodeId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nodes/{nodeId}");
|
||||
var result = await HttpHelper.HandleResponse<NodeResponse>(response);
|
||||
return result?.Node;
|
||||
}
|
||||
|
||||
public async Task<NodeConfiguration?> GetNodeConfiguration(int nodeId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nodes/{nodeId}/configuration");
|
||||
return await HttpHelper.HandleResponse<NodeConfiguration>(response);
|
||||
}
|
||||
|
||||
|
||||
public async Task<Node?> CreateNode(NodeCreateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/application/nodes", content);
|
||||
var result = await HttpHelper.HandleResponse<NodeResponse>(response);
|
||||
return result?.Node;
|
||||
}
|
||||
|
||||
public async Task<Node?> UpdateNode(int nodeId, NodeUpdateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PatchAsync($"{BaseUrl}/api/application/nodes/{nodeId}", content);
|
||||
var result = await HttpHelper.HandleResponse<NodeResponse>(response);
|
||||
return result?.Node;
|
||||
}
|
||||
|
||||
public async Task DeleteNode(int nodeId)
|
||||
{
|
||||
var response = await HttpClient.DeleteAsync($"{BaseUrl}/api/application/nodes/{nodeId}");
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task<List<Allocation>?> GetNodeAllocations(int nodeId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nodes/{nodeId}/allocations");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<AllocationResponse>>(response);
|
||||
return result?.Data.Select(r => r.Allocation).ToList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Servers
|
||||
|
||||
public async Task<List<Server>?> ListServers()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/servers");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<ServerResponse>>(response);
|
||||
|
||||
return result?.Data.Select(r => r.Server).ToList() ?? [];
|
||||
}
|
||||
|
||||
public async Task<Server?> GetServer(int serverId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/servers/{serverId}");
|
||||
var result = await HttpHelper.HandleResponse<ServerResponse>(response);
|
||||
return result?.Server;
|
||||
}
|
||||
|
||||
public async Task<Server?> GetServerByExternalId(string externalId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/servers/external/{externalId}");
|
||||
var result = await HttpHelper.HandleResponse<ServerResponse>(response);
|
||||
return result?.Server;
|
||||
}
|
||||
|
||||
public async Task<Server?> CreateServer(ServerCreateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/application/servers", content);
|
||||
var result = await HttpHelper.HandleResponse<ServerResponse>(response);
|
||||
return result?.Server;
|
||||
}
|
||||
|
||||
public async Task<Server?> UpdateServerDetails(int serverId,
|
||||
ServerDetailsUpdateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response =
|
||||
await HttpClient.PatchAsync($"{BaseUrl}/api/application/servers/{serverId}/details", content);
|
||||
var result = await HttpHelper.HandleResponse<ServerResponse>(response);
|
||||
return result?.Server;
|
||||
}
|
||||
|
||||
public async Task SuspendServer(int serverId)
|
||||
{
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/application/servers/{serverId}/suspend", null);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task UnSuspendServer(int serverId)
|
||||
{
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/application/servers/{serverId}/unsuspend", null);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task ReinstallServer(int serverId)
|
||||
{
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/application/servers/{serverId}/reinstall", null);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task DeleteServer(int serverId, bool force = false)
|
||||
{
|
||||
var url = $"{BaseUrl}/api/application/servers/{serverId}" + (force ? "/force" : "");
|
||||
var response = await HttpClient.DeleteAsync(url);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Locations
|
||||
|
||||
public async Task<List<Location>?> ListLocations()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/locations");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<LocationResponse>>(response);
|
||||
return result?.Data.Select(r => r.Location).ToList() ?? [];
|
||||
}
|
||||
|
||||
public async Task<Location?> CreateLocation(LocationCreateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/application/locations", content);
|
||||
var result = await HttpHelper.HandleResponse<LocationResponse>(response);
|
||||
return result?.Location;
|
||||
}
|
||||
|
||||
public async Task<Location?> UpdateLocation(int locationId, LocationUpdateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PatchAsync($"{BaseUrl}/api/application/locations/{locationId}", content);
|
||||
var result = await HttpHelper.HandleResponse<LocationResponse>(response);
|
||||
return result?.Location;
|
||||
}
|
||||
|
||||
public async Task DeleteLocation(int locationId)
|
||||
{
|
||||
var response = await HttpClient.DeleteAsync($"{BaseUrl}/api/application/locations/{locationId}");
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Databases 一般弃用 暂不进行适配
|
||||
|
||||
public async Task<PaginatedResult<ServerDatabaseResponse>?> ListServerDatabases(int serverId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/servers/{serverId}/databases");
|
||||
return await HttpHelper.HandleResponse<PaginatedResult<ServerDatabaseResponse>>(response);
|
||||
}
|
||||
|
||||
public async Task<ServerDatabaseResponse?> CreateServerDatabase(int serverId, DatabaseCreateRequest request)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
|
||||
var response =
|
||||
await HttpClient.PostAsync($"{BaseUrl}/api/application/servers/{serverId}/databases", content);
|
||||
return await HttpHelper.HandleResponse<ServerDatabaseResponse>(response);
|
||||
}
|
||||
|
||||
public async Task ResetDatabasePassword(int serverId, int databaseId)
|
||||
{
|
||||
var response = await HttpClient.PostAsync(
|
||||
$"{BaseUrl}/api/application/servers/{serverId}/databases/{databaseId}/reset-password", null);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task DeleteServerDatabase(int serverId, int databaseId)
|
||||
{
|
||||
var response = await HttpClient.DeleteAsync(
|
||||
$"{BaseUrl}/api/application/servers/{serverId}/databases/{databaseId}");
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nests
|
||||
|
||||
public async Task<List<Nest>?> ListNests()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nests");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<NestResponse>>(response);
|
||||
return result?.Data.Select(n => n.Nest).ToList() ?? [];
|
||||
}
|
||||
|
||||
public async Task<Nest?> GetNest(int nestId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nests/{nestId}");
|
||||
var result = await HttpHelper.HandleResponse<NestResponse>(response);
|
||||
return result?.Nest;
|
||||
}
|
||||
|
||||
public async Task<List<Egg?>> ListNestEggs(int nestId, bool includeNest = false, bool includeServers = false)
|
||||
{
|
||||
var includes = new List<string>();
|
||||
if (includeNest) includes.Add("nest");
|
||||
if (includeServers) includes.Add("servers");
|
||||
|
||||
var query = includes.Any()
|
||||
? $"?include={string.Join(",", includes)}"
|
||||
: string.Empty;
|
||||
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nests/{nestId}/eggs{query}");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<EggResponse>>(response);
|
||||
|
||||
return result?.Data.Select(r => r.Egg).ToList() ?? [];
|
||||
}
|
||||
|
||||
public async Task<Egg?> GetEgg(int nestId, int eggId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/application/nests/{nestId}/eggs/{eggId}");
|
||||
var result = await HttpHelper.HandleResponse<EggResponse>(response);
|
||||
return result?.Egg;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
124
Pterodactyl.NETSDK/Client.cs
Normal file
124
Pterodactyl.NETSDK/Client.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Pterodactyl.NETSDK.Helper;
|
||||
using Pterodactyl.NETSDK.Models.Client.Account;
|
||||
using Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
using Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
namespace Pterodactyl.NETSDK;
|
||||
|
||||
public class Client(string baseUrl, string apiKey) : PterodactylClient(baseUrl, apiKey)
|
||||
{
|
||||
public async Task<List<Server?>> ListServers()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/client");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<ServerResponse>>(response);
|
||||
return result?.Data.Select(r => r.Server).ToList() ?? [];
|
||||
}
|
||||
|
||||
public async Task<Account?> GetAccountDetails()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/client/account");
|
||||
var result = await HttpHelper.HandleResponse<AccountResponse>(response);
|
||||
return result?.Account;
|
||||
}
|
||||
|
||||
public async Task<TwoFactorDetails?> GetTwoFactorDetails()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/client/account/two-factor");
|
||||
var result = await HttpHelper.HandleResponse<TwoFactorDetailsResponse>(response);
|
||||
return result?.TwoFactorDetails;
|
||||
}
|
||||
|
||||
public async Task<TwoFactorEnableResponse?> EnableTwoFactor(string code)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(new { code }), Encoding.UTF8, "application/json");
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/client/account/two-factor", content);
|
||||
return await HttpHelper.HandleResponse<TwoFactorEnableResponse>(response);
|
||||
}
|
||||
|
||||
public async Task DisableTwoFactor(string password)
|
||||
{
|
||||
var requestBody = new { password };
|
||||
var content = new StringContent(JsonSerializer.Serialize(requestBody), Encoding.UTF8, "application/json");
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, $"{BaseUrl}/api/client/account/two-factor")
|
||||
{
|
||||
Content = content
|
||||
};
|
||||
|
||||
var response = await HttpClient.SendAsync(request);
|
||||
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task UpdateEmail(string email, string password)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(new { email, password }), Encoding.UTF8,
|
||||
"application/json");
|
||||
var response = await HttpClient.PutAsync($"{BaseUrl}/api/client/account/email", content);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task UpdatePassword(string currentPassword, string newPassword, string confirmPassword)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(new
|
||||
{
|
||||
current_password = currentPassword,
|
||||
password = newPassword,
|
||||
password_confirmation = confirmPassword
|
||||
}), Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await HttpClient.PutAsync($"{BaseUrl}/api/client/account/password", content);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task<List<ApiKey>?> ListApiKeys()
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/client/account/api-keys");
|
||||
var result = await HttpHelper.HandleResponse<PaginatedResult<ApiKeyResponse>>(response);
|
||||
return result?.Data.Select(r => r.ApiKey).ToList();
|
||||
}
|
||||
|
||||
public async Task<ApiKeyWithSecret?> CreateApiKey(string description, List<string>? allowedIps = null)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(new
|
||||
{
|
||||
description,
|
||||
allowed_ips = allowedIps ?? []
|
||||
}), Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/client/account/api-keys", content);
|
||||
var result = await HttpHelper.HandleResponse<ApiKeyCreateResponse>(response);
|
||||
return result?.ApiKeyWithSecret;
|
||||
}
|
||||
|
||||
public async Task DeleteApiKey(string identifier)
|
||||
{
|
||||
var response = await HttpClient.DeleteAsync($"{BaseUrl}/api/client/account/api-keys/{identifier}");
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task<Server?> GetServerDetails(string serverId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync($"{BaseUrl}/api/client/servers/{serverId}");
|
||||
var result = await HttpHelper.HandleResponse<ServerResponse>(response);
|
||||
return result?.Server;
|
||||
}
|
||||
|
||||
public async Task SendCommand(string serverId, string command)
|
||||
{
|
||||
var content = new StringContent(JsonSerializer.Serialize(new { command }), Encoding.UTF8,
|
||||
"application/json");
|
||||
var response = await HttpClient.PostAsync($"{BaseUrl}/api/client/servers/{serverId}/command", content);
|
||||
await HttpHelper.HandleResponse(response);
|
||||
}
|
||||
|
||||
public async Task<WebSocketCredentials?> GetWebSocketCredentials(string serverId)
|
||||
{
|
||||
var response = await HttpClient.GetAsync(
|
||||
$"{BaseUrl}/api/client/servers/{serverId}/websocket"
|
||||
);
|
||||
return (await HttpHelper.HandleResponse<WebSocketResponse>(response))?.Data;
|
||||
}
|
||||
}
|
||||
3
Pterodactyl.NETSDK/Exceptions/PterodactylApiException.cs
Normal file
3
Pterodactyl.NETSDK/Exceptions/PterodactylApiException.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Pterodactyl.NETSDK.Exceptions;
|
||||
|
||||
public class PterodactylApiException(string message) : Exception(message);
|
||||
1
Pterodactyl.NETSDK/GlobalUsings.cs
Normal file
1
Pterodactyl.NETSDK/GlobalUsings.cs
Normal file
@@ -0,0 +1 @@
|
||||
global using System.Text.Json.Serialization;
|
||||
43
Pterodactyl.NETSDK/Helper/HttpHelper.cs
Normal file
43
Pterodactyl.NETSDK/Helper/HttpHelper.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Text.Json;
|
||||
using Pterodactyl.NETSDK.Exceptions;
|
||||
|
||||
namespace Pterodactyl.NETSDK.Helper;
|
||||
|
||||
internal static class HttpHelper
|
||||
{
|
||||
public static async Task<T?> HandleResponse<T>(HttpResponseMessage response)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
throw new PterodactylApiException(
|
||||
$"API请求失败,状态码: {response.StatusCode}" +
|
||||
response.StatusCode +
|
||||
content
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(content);
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
throw new PterodactylApiException(
|
||||
$"JSON解析失败: {ex.Message}" +
|
||||
response.StatusCode +
|
||||
content +
|
||||
ex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
throw new PterodactylApiException(
|
||||
$"API request failed with status code {response.StatusCode}: {errorContent}");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Pterodactyl.NETSDK/Models/Application/Locations/Location.cs
Normal file
10
Pterodactyl.NETSDK/Models/Application/Locations/Location.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Locations;
|
||||
|
||||
public class Location
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("short")] public string? ShortCode { get; set; }
|
||||
[JsonPropertyName("long")] public string? LongName { get; set; }
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Locations;
|
||||
|
||||
public class LocationResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public Location? Location { get; set; }
|
||||
}
|
||||
15
Pterodactyl.NETSDK/Models/Application/Nests/Eggs/Egg.cs
Normal file
15
Pterodactyl.NETSDK/Models/Application/Nests/Eggs/Egg.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests.Eggs;
|
||||
|
||||
public class Egg
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("uuid")] public string? Uuid { get; set; }
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
[JsonPropertyName("docker_image")] public string? DockerImage { get; set; }
|
||||
[JsonPropertyName("config")] public EggConfig? Config { get; set; }
|
||||
[JsonPropertyName("startup")] public string? StartupCommand { get; set; }
|
||||
[JsonPropertyName("script")] public EggScript? Script { get; set; }
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests.Eggs;
|
||||
|
||||
public class EggConfig
|
||||
{
|
||||
[JsonPropertyName("files")] public Dictionary<string, FileConfig>? Files { get; set; }
|
||||
[JsonPropertyName("startup")] public StartupConfig? Startup { get; set; }
|
||||
[JsonPropertyName("stop")] public string? StopSign { get; set; }
|
||||
[JsonPropertyName("logs")] public List<LogConfig>? Logs { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests.Eggs;
|
||||
|
||||
public class EggResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public Egg? Egg { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests.Eggs;
|
||||
|
||||
public class EggScript
|
||||
{
|
||||
[JsonPropertyName("privileged")] public bool Privileged { get; set; }
|
||||
[JsonPropertyName("install")] public string? InstallScript { get; set; }
|
||||
[JsonPropertyName("entry")] public string? EntryPoint { get; set; }
|
||||
[JsonPropertyName("container")] public string? ContainerImage { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests.Eggs;
|
||||
|
||||
public class FileConfig
|
||||
{
|
||||
[JsonPropertyName("parser")] public string? Parser { get; set; }
|
||||
[JsonPropertyName("find")] public Dictionary<string, object>? FindReplace { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests.Eggs;
|
||||
|
||||
public class LogConfig
|
||||
{
|
||||
[JsonPropertyName("custom")] public bool IsCustom { get; set; }
|
||||
[JsonPropertyName("location")] public string? Location { get; set; }
|
||||
}
|
||||
12
Pterodactyl.NETSDK/Models/Application/Nests/Nest.cs
Normal file
12
Pterodactyl.NETSDK/Models/Application/Nests/Nest.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests;
|
||||
|
||||
public class Nest
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("uuid")] public string? Uuid { get; set; }
|
||||
[JsonPropertyName("author")] public string? Author { get; set; }
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nests;
|
||||
|
||||
public class NestResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public Nest? Nest { get; set; }
|
||||
}
|
||||
31
Pterodactyl.NETSDK/Models/Application/Nodes/Node.cs
Normal file
31
Pterodactyl.NETSDK/Models/Application/Nodes/Node.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
|
||||
public class Node
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("uuid")] public string? Uuid { get; set; }
|
||||
[JsonPropertyName("public")] public bool Public { get; set; }
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
[JsonPropertyName("location_id")] public int LocationId { get; set; }
|
||||
[JsonPropertyName("fqdn")] public string? Fqdn { get; set; }
|
||||
[JsonPropertyName("scheme")] public string? Scheme { get; set; }
|
||||
[JsonPropertyName("behind_proxy")] public bool BehindProxy { get; set; }
|
||||
[JsonPropertyName("maintenance_mode")] public bool MaintenanceMode { get; set; }
|
||||
[JsonPropertyName("memory")] public int Memory { get; set; }
|
||||
|
||||
[JsonPropertyName("memory_overallocate")]
|
||||
public int MemoryOverallocate { get; set; }
|
||||
|
||||
[JsonPropertyName("disk")] public int Disk { get; set; }
|
||||
|
||||
[JsonPropertyName("disk_overallocate")]
|
||||
public int DiskOverallocate { get; set; }
|
||||
|
||||
[JsonPropertyName("upload_size")] public int UploadSize { get; set; }
|
||||
[JsonPropertyName("daemon_listen")] public int DaemonListen { get; set; }
|
||||
[JsonPropertyName("daemon_sftp")] public int DaemonSftp { get; set; }
|
||||
[JsonPropertyName("daemon_base")] public string? DaemonBase { get; set; }
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
|
||||
public class NodeApiConfig
|
||||
{
|
||||
[JsonPropertyName("host")] public string? Host { get; set; }
|
||||
[JsonPropertyName("port")] public int Port { get; set; }
|
||||
[JsonPropertyName("ssl")] public NodeSslConfig? Ssl { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
|
||||
public class NodeConfiguration
|
||||
{
|
||||
[JsonPropertyName("debug")] public bool Debug { get; set; }
|
||||
[JsonPropertyName("uuid")] public string? Uuid { get; set; }
|
||||
[JsonPropertyName("token_id")] public string? TokenId { get; set; }
|
||||
[JsonPropertyName("token")] public string? Token { get; set; }
|
||||
[JsonPropertyName("api")] public NodeApiConfig? Api { get; set; }
|
||||
[JsonPropertyName("system")] public NodeSystemConfig? System { get; set; }
|
||||
[JsonPropertyName("remote")] public string? Remote { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
|
||||
public class NodeResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public Node? Node { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
|
||||
public class NodeSftpConfig
|
||||
{
|
||||
[JsonPropertyName("bind_port")] public int Port { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
|
||||
public class NodeSslConfig
|
||||
{
|
||||
[JsonPropertyName("enabled")] public bool Enabled { get; set; }
|
||||
[JsonPropertyName("cert")] public string? Certificate { get; set; }
|
||||
[JsonPropertyName("key")] public string? Key { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Nodes;
|
||||
|
||||
public class NodeSystemConfig
|
||||
{
|
||||
[JsonPropertyName("data")] public string? DataPath { get; set; }
|
||||
[JsonPropertyName("sftp")] public NodeSftpConfig? Sftp { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
public class ContainerDetails
|
||||
{
|
||||
[JsonPropertyName("startup_command")] public string? StartupCommand { get; set; }
|
||||
|
||||
[JsonPropertyName("image")] public string? Image { get; set; }
|
||||
|
||||
[JsonPropertyName("installed")] public int Installed { get; set; }
|
||||
|
||||
[JsonPropertyName("environment")] public Dictionary<string, object>? Environment { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
public static class ContainerExtensions
|
||||
{
|
||||
public static T? GetEnvironmentValue<T>(Dictionary<string, object> env, string key)
|
||||
{
|
||||
if (env.TryGetValue(key, out var value) && value is T typedValue) return typedValue;
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
24
Pterodactyl.NETSDK/Models/Application/Servers/Server.cs
Normal file
24
Pterodactyl.NETSDK/Models/Application/Servers/Server.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
public class Server
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("identifier")] public string? Identifier { get; set; }
|
||||
[JsonPropertyName("external_id")] public string? ExternalId { get; set; }
|
||||
[JsonPropertyName("uuid")] public string? Uuid { get; set; }
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
[JsonPropertyName("suspended")] public bool IsSuspended { get; set; }
|
||||
[JsonPropertyName("limits")] public ServerLimits? Limits { get; set; }
|
||||
[JsonPropertyName("feature_limits")] public ServerFeatureLimits? FeatureLimits { get; set; }
|
||||
[JsonPropertyName("user")] public int User { get; set; }
|
||||
[JsonPropertyName("node")] public int Node { get; set; }
|
||||
[JsonPropertyName("allocation")] public int Allocation { get; set; }
|
||||
[JsonPropertyName("nest")] public int Nest { get; set; }
|
||||
[JsonPropertyName("egg")] public int Egg { get; set; }
|
||||
[JsonPropertyName("container")] public ContainerDetails? Container { get; set; }
|
||||
[JsonPropertyName("updated_at")] public DateTime? UpdateAt { get; set; }
|
||||
[JsonPropertyName("created_at")] public DateTime? CreatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
public class ServerDatabase
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("server")] public int ServerId { get; set; }
|
||||
[JsonPropertyName("host")] public int HostId { get; set; }
|
||||
[JsonPropertyName("database")] public string? DatabaseName { get; set; }
|
||||
[JsonPropertyName("username")] public string? Username { get; set; }
|
||||
[JsonPropertyName("remote")] public string? RemoteAccess { get; set; }
|
||||
[JsonPropertyName("max_connections")] public int MaxConnections { get; set; }
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
public class ServerDatabaseResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public ServerDatabase? ServerDatabase { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
public class ServerResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
[JsonPropertyName("attributes")] public Server? Server { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Servers;
|
||||
|
||||
public class StartupConfig
|
||||
{
|
||||
[JsonPropertyName("done")] public string? CompletionExpression { get; set; }
|
||||
[JsonPropertyName("userInteraction")] public List<string>? UserInteractions { get; set; }
|
||||
}
|
||||
28
Pterodactyl.NETSDK/Models/Application/Users/User.cs
Normal file
28
Pterodactyl.NETSDK/Models/Application/Users/User.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Users;
|
||||
|
||||
public class User
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
|
||||
[JsonPropertyName("external_id")] public string? ExternalId { get; set; }
|
||||
|
||||
[JsonPropertyName("uuid")] public string? Uuid { get; set; }
|
||||
|
||||
[JsonPropertyName("username")] public string? Username { get; set; }
|
||||
|
||||
[JsonPropertyName("email")] public string? Email { get; set; }
|
||||
|
||||
[JsonPropertyName("first_name")] public string? FirstName { get; set; }
|
||||
|
||||
[JsonPropertyName("last_name")] public string? LastName { get; set; }
|
||||
|
||||
[JsonPropertyName("language")] public string? Language { get; set; }
|
||||
|
||||
[JsonPropertyName("root_admin")] public bool IsRootAdmin { get; set; }
|
||||
|
||||
[JsonPropertyName("2fa")] public bool TwoFactorEnabled { get; set; }
|
||||
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
|
||||
[JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Application.Users;
|
||||
|
||||
public class UserResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
[JsonPropertyName("attributes")] public User? User { get; set; }
|
||||
}
|
||||
12
Pterodactyl.NETSDK/Models/Client/Account/Account.cs
Normal file
12
Pterodactyl.NETSDK/Models/Client/Account/Account.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class Account
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("admin")] public bool Admin { get; set; }
|
||||
[JsonPropertyName("username")] public string? Username { get; set; }
|
||||
[JsonPropertyName("email")] public string? Email { get; set; }
|
||||
[JsonPropertyName("first_name")] public string? FirstName { get; set; }
|
||||
[JsonPropertyName("last_name")] public string? LastName { get; set; }
|
||||
[JsonPropertyName("language")] public string? Language { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class AccountResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
[JsonPropertyName("attributes")] public Account? Account { get; set; }
|
||||
}
|
||||
14
Pterodactyl.NETSDK/Models/Client/Account/ApiKey.cs
Normal file
14
Pterodactyl.NETSDK/Models/Client/Account/ApiKey.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class ApiKey
|
||||
{
|
||||
[JsonPropertyName("identifier")] public string? Identifier { get; set; }
|
||||
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
|
||||
[JsonPropertyName("allowed_ips")] public List<string>? AllowedIps { get; set; }
|
||||
|
||||
[JsonPropertyName("last_used_at")] public DateTime? LastUsedAt { get; set; }
|
||||
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class ApiKeyCreateResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public ApiKeyWithSecret? ApiKeyWithSecret { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class ApiKeyResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public ApiKey? ApiKey { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class ApiKeyWithSecret : ApiKey
|
||||
{
|
||||
[JsonPropertyName("token")] public string? SecretToken { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class TwoFactorDetails
|
||||
{
|
||||
[JsonPropertyName("image_url_data")] public string? ImageUrlData { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class TwoFactorDetailsResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
[JsonPropertyName("attributes")] public TwoFactorDetails? TwoFactorDetails { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Account;
|
||||
|
||||
public class TwoFactorEnableResponse
|
||||
{
|
||||
[JsonPropertyName("tokens")] public List<string>? Tokens { get; set; }
|
||||
[JsonPropertyName("allowed_ips")] public List<string>? AllowedIps { get; set; }
|
||||
[JsonPropertyName("last_used_at")] public DateTime? LastUsedAt { get; set; }
|
||||
[JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
10
Pterodactyl.NETSDK/Models/Client/Servers/AllocationList.cs
Normal file
10
Pterodactyl.NETSDK/Models/Client/Servers/AllocationList.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Pterodactyl.NETSDK.Models.Common.Allocations;
|
||||
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class AllocationList
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("data")] public List<AllocationResponse>? Data { get; set; }
|
||||
}
|
||||
10
Pterodactyl.NETSDK/Models/Client/Servers/ResourceStats.cs
Normal file
10
Pterodactyl.NETSDK/Models/Client/Servers/ResourceStats.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class ResourceStats
|
||||
{
|
||||
[JsonPropertyName("memory_bytes")] public long MemoryBytes { get; set; }
|
||||
[JsonPropertyName("cpu_absolute")] public long CpuAbsolute { get; set; }
|
||||
[JsonPropertyName("disk_bytes")] public long DiskBytes { get; set; }
|
||||
[JsonPropertyName("network_rx_bytes")] public long NetworkRxBytes { get; set; }
|
||||
[JsonPropertyName("network_tx_bytes")] public long NetworkTxBytes { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class ResourceUsage
|
||||
{
|
||||
[JsonPropertyName("current_state")] public string? CurrentState { get; set; }
|
||||
[JsonPropertyName("is_suspended")] public bool IsSuspended { get; set; }
|
||||
[JsonPropertyName("resources")] public ResourceStats? Resources { get; set; }
|
||||
}
|
||||
30
Pterodactyl.NETSDK/Models/Client/Servers/Server.cs
Normal file
30
Pterodactyl.NETSDK/Models/Client/Servers/Server.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class Server
|
||||
{
|
||||
[JsonPropertyName("server_owner")] public bool IsServerOwner { get; set; }
|
||||
|
||||
[JsonPropertyName("identifier")] public string? Identifier { get; set; }
|
||||
|
||||
[JsonPropertyName("uuid")] public string? Uuid { get; set; }
|
||||
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
|
||||
[JsonPropertyName("node")] public string? NodeName { get; set; }
|
||||
|
||||
[JsonPropertyName("sftp_details")] public SftpDetails? SftpDetails { get; set; }
|
||||
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
|
||||
[JsonPropertyName("limits")] public ServerLimits? Limits { get; set; }
|
||||
|
||||
[JsonPropertyName("feature_limits")] public ServerFeatureLimits? FeatureLimits { get; set; }
|
||||
|
||||
[JsonPropertyName("is_suspended")] public bool IsSuspended { get; set; }
|
||||
|
||||
[JsonPropertyName("is_installing")] public bool IsInstalling { get; set; }
|
||||
|
||||
[JsonPropertyName("relationships")] public ServerRelationships? Relationships { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class ServerRelationships
|
||||
{
|
||||
[JsonPropertyName("allocations")] public AllocationList? Allocations { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class ServerResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("attributes")] public Server? Server { get; set; }
|
||||
}
|
||||
8
Pterodactyl.NETSDK/Models/Client/Servers/SftpDetails.cs
Normal file
8
Pterodactyl.NETSDK/Models/Client/Servers/SftpDetails.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class SftpDetails
|
||||
{
|
||||
[JsonPropertyName("ip")] public string? Ip { get; set; }
|
||||
|
||||
[JsonPropertyName("port")] public int Port { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class WebSocketCredentials
|
||||
{
|
||||
[JsonPropertyName("token")] public string? Token { get; set; }
|
||||
|
||||
[JsonPropertyName("socket")] public string? SocketUrl { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Client.Servers;
|
||||
|
||||
public class WebSocketResponse
|
||||
{
|
||||
[JsonPropertyName("data")] public WebSocketCredentials? Data { get; set; }
|
||||
}
|
||||
10
Pterodactyl.NETSDK/Models/Common/Allocations/Allocation.cs
Normal file
10
Pterodactyl.NETSDK/Models/Common/Allocations/Allocation.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common.Allocations;
|
||||
|
||||
public class Allocation
|
||||
{
|
||||
[JsonPropertyName("id")] public int Id { get; set; }
|
||||
[JsonPropertyName("ip")] public string? Ip { get; set; }
|
||||
[JsonPropertyName("port")] public int Port { get; set; }
|
||||
[JsonPropertyName("notes")] public string? Notes { get; set; }
|
||||
[JsonPropertyName("is_default")] public bool IsDefault { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common.Allocations;
|
||||
|
||||
public class AllocationResponse
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
[JsonPropertyName("attributes")] public Allocation? Allocation { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common.Allocations;
|
||||
|
||||
public class AllocationSettings
|
||||
{
|
||||
[JsonPropertyName("default")] public int DefaultAllocation { get; set; }
|
||||
|
||||
[JsonPropertyName("additional")] public List<int> AdditionalAllocations { get; set; } = new();
|
||||
}
|
||||
10
Pterodactyl.NETSDK/Models/Common/PaginatedResult.cs
Normal file
10
Pterodactyl.NETSDK/Models/Common/PaginatedResult.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
public class PaginatedResult<T>
|
||||
{
|
||||
[JsonPropertyName("object")] public string? ObjectType { get; set; }
|
||||
|
||||
[JsonPropertyName("data")] public List<T>? Data { get; set; }
|
||||
|
||||
[JsonPropertyName("meta")] public PaginationMeta? Meta { get; set; }
|
||||
}
|
||||
10
Pterodactyl.NETSDK/Models/Common/PaginationDetails.cs
Normal file
10
Pterodactyl.NETSDK/Models/Common/PaginationDetails.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
public class PaginationDetails
|
||||
{
|
||||
[JsonPropertyName("total")] public int Total { get; set; }
|
||||
[JsonPropertyName("count")] public int Count { get; set; }
|
||||
[JsonPropertyName("per_page")] public int PerPage { get; set; }
|
||||
[JsonPropertyName("current_page")] public int CurrentPage { get; set; }
|
||||
[JsonPropertyName("total_pages")] public int TotalPages { get; set; }
|
||||
}
|
||||
6
Pterodactyl.NETSDK/Models/Common/PaginationMeta.cs
Normal file
6
Pterodactyl.NETSDK/Models/Common/PaginationMeta.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
public class PaginationMeta
|
||||
{
|
||||
[JsonPropertyName("pagination")] public PaginationDetails? Pagination { get; set; }
|
||||
}
|
||||
8
Pterodactyl.NETSDK/Models/Common/ServerFeatureLimits.cs
Normal file
8
Pterodactyl.NETSDK/Models/Common/ServerFeatureLimits.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
public class ServerFeatureLimits
|
||||
{
|
||||
[JsonPropertyName("databases")] public int Databases { get; set; }
|
||||
[JsonPropertyName("allocations")] public int Allocations { get; set; }
|
||||
[JsonPropertyName("backups")] public int Backups { get; set; }
|
||||
}
|
||||
10
Pterodactyl.NETSDK/Models/Common/ServerLimits.cs
Normal file
10
Pterodactyl.NETSDK/Models/Common/ServerLimits.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Pterodactyl.NETSDK.Models.Common;
|
||||
|
||||
public class ServerLimits
|
||||
{
|
||||
[JsonPropertyName("memory")] public int Memory { get; set; }
|
||||
[JsonPropertyName("swap")] public int Swap { get; set; }
|
||||
[JsonPropertyName("disk")] public int Disk { get; set; }
|
||||
[JsonPropertyName("io")] public int Io { get; set; }
|
||||
[JsonPropertyName("cpu")] public int Cpu { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Library</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
8
Pterodactyl.NETSDK/Request/DatabaseCreateRequest.cs
Normal file
8
Pterodactyl.NETSDK/Request/DatabaseCreateRequest.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class DatabaseCreateRequest
|
||||
{
|
||||
[JsonPropertyName("database")] public string? DatabaseName { get; set; }
|
||||
[JsonPropertyName("remote")] public string? RemoteAccess { get; set; }
|
||||
[JsonPropertyName("host")] public int HostId { get; set; }
|
||||
}
|
||||
7
Pterodactyl.NETSDK/Request/LocationCreateRequest.cs
Normal file
7
Pterodactyl.NETSDK/Request/LocationCreateRequest.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class LocationCreateRequest
|
||||
{
|
||||
[JsonPropertyName("short")] public string? ShortCode { get; set; }
|
||||
[JsonPropertyName("long")] public string? LongName { get; set; }
|
||||
}
|
||||
5
Pterodactyl.NETSDK/Request/LocationUpdateRequest.cs
Normal file
5
Pterodactyl.NETSDK/Request/LocationUpdateRequest.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class LocationUpdateRequest : LocationCreateRequest
|
||||
{
|
||||
}
|
||||
22
Pterodactyl.NETSDK/Request/NodeCreateRequest.cs
Normal file
22
Pterodactyl.NETSDK/Request/NodeCreateRequest.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class NodeCreateRequest
|
||||
{
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
[JsonPropertyName("location_id")] public int LocationId { get; set; }
|
||||
[JsonPropertyName("fqdn")] public string? Fqdn { get; set; }
|
||||
[JsonPropertyName("scheme")] public string? Scheme { get; set; }
|
||||
[JsonPropertyName("memory")] public int Memory { get; set; }
|
||||
|
||||
[JsonPropertyName("memory_overallocate")]
|
||||
public int MemoryOverallocation { get; set; }
|
||||
|
||||
[JsonPropertyName("disk")] public int Disk { get; set; }
|
||||
|
||||
[JsonPropertyName("disk_overallocate")]
|
||||
public int DiskOverallocation { get; set; }
|
||||
|
||||
[JsonPropertyName("upload_size")] public int UploadSize { get; set; }
|
||||
[JsonPropertyName("daemon_sftp")] public int SftpPort { get; set; }
|
||||
[JsonPropertyName("daemon_listen")] public int DaemonPort { get; set; }
|
||||
}
|
||||
8
Pterodactyl.NETSDK/Request/NodeUpdateRequest.cs
Normal file
8
Pterodactyl.NETSDK/Request/NodeUpdateRequest.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class NodeUpdateRequest : NodeCreateRequest
|
||||
{
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
[JsonPropertyName("behind_proxy")] public bool BehindProxy { get; set; }
|
||||
[JsonPropertyName("maintenance_mode")] public bool MaintenanceMode { get; set; }
|
||||
}
|
||||
20
Pterodactyl.NETSDK/Request/ServerCreateRequest.cs
Normal file
20
Pterodactyl.NETSDK/Request/ServerCreateRequest.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Pterodactyl.NETSDK.Models.Common;
|
||||
using Pterodactyl.NETSDK.Models.Common.Allocations;
|
||||
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class ServerCreateRequest
|
||||
{
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
[JsonPropertyName("user")] public int UserId { get; set; }
|
||||
[JsonPropertyName("egg")] public int EggId { get; set; }
|
||||
[JsonPropertyName("node")] public int NodeId { get; set; }
|
||||
|
||||
[JsonPropertyName("allocation")] public AllocationSettings Allocation { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("docker_image")] public string? DockerImage { get; set; }
|
||||
[JsonPropertyName("startup")] public string? StartupCommand { get; set; }
|
||||
[JsonPropertyName("environment")] public Dictionary<string, string>? Environment { get; set; }
|
||||
[JsonPropertyName("limits")] public ServerLimits? Limits { get; set; }
|
||||
[JsonPropertyName("feature_limits")] public ServerFeatureLimits? FeatureLimits { get; set; }
|
||||
}
|
||||
9
Pterodactyl.NETSDK/Request/ServerDetailsUpdateRequest.cs
Normal file
9
Pterodactyl.NETSDK/Request/ServerDetailsUpdateRequest.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class ServerDetailsUpdateRequest
|
||||
{
|
||||
[JsonPropertyName("name")] public string? Name { get; set; }
|
||||
[JsonPropertyName("user")] public int UserId { get; set; }
|
||||
[JsonPropertyName("external_id")] public string? ExternalId { get; set; }
|
||||
[JsonPropertyName("description")] public string? Description { get; set; }
|
||||
}
|
||||
11
Pterodactyl.NETSDK/Request/UserCreateRequest.cs
Normal file
11
Pterodactyl.NETSDK/Request/UserCreateRequest.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class UserCreateRequest
|
||||
{
|
||||
[JsonPropertyName("email")] public string? Email { get; set; }
|
||||
[JsonPropertyName("username")] public string? Username { get; set; }
|
||||
[JsonPropertyName("first_name")] public string? FirstName { get; set; }
|
||||
[JsonPropertyName("last_name")] public string? LastName { get; set; }
|
||||
[JsonPropertyName("password")] public string? Password { get; set; }
|
||||
[JsonPropertyName("root_admin")] public bool IsRootAdmin { get; set; }
|
||||
}
|
||||
6
Pterodactyl.NETSDK/Request/UserUpdateRequest.cs
Normal file
6
Pterodactyl.NETSDK/Request/UserUpdateRequest.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Pterodactyl.NETSDK.Request;
|
||||
|
||||
public class UserUpdateRequest : UserCreateRequest
|
||||
{
|
||||
[JsonPropertyName("language")] public string? Language { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user