From 5fe17f1098be01b2f2dad655da114693a293b0f0 Mon Sep 17 00:00:00 2001 From: Chris L Date: Wed, 17 Apr 2024 19:20:45 -0600 Subject: [PATCH 01/11] add external selection --- .../application/entities/PteroApplication.java | 3 +++ .../application/entities/impl/PteroApplicationImpl.java | 9 +++++++++ .../java/com/mattmalec/pterodactyl4j/requests/Route.java | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index 2aec38a..7f33649 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -552,6 +552,9 @@ default PteroAction retrieveServerById(long id) { * * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link java.util.List List} of {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationServer ApplicationServers} */ + + PteroAction retrieveServerByExternalId(String id); + PteroAction> retrieveServersByName(String name, boolean caseSensitive); /** diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java index 87af8ad..3e5019f 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java @@ -276,6 +276,15 @@ public PaginationAction retrieveServers() { api, Route.Servers.LIST_SERVERS.compile(), (object) -> new ApplicationServerImpl(this, object)); } + @Override + public PteroAction retrieveServerByExternalId(String id) { + return PteroActionImpl.onRequestExecute( + api, + Route.Servers.GET_SERVER_EXTERNAL.compile(id), + (response, request) -> new ApplicationServerImpl(this, response.getObject()) + ); + } + @Override public PteroAction retrieveServerById(String id) { return PteroActionImpl.onRequestExecute( diff --git a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java index d5beadc..ca03762 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java @@ -73,6 +73,8 @@ public static class Servers { GET, APPLICATION_PREFIX + "servers/{server_id}?include=allocations,user,subusers,nest,egg,location,node,databases"); + public static final Route GET_SERVER_EXTERNAL = + new Route(GET, APPLICATION_PREFIX + "servers/external/{external_id}" ); public static final Route UPDATE_SERVER_DETAILS = new Route(PATCH, APPLICATION_PREFIX + "servers/{server_id}/details"); public static final Route UPDATE_SERVER_BUILD = From 3e16b9290c284844bb8616eba4feaeedbfbd9d38 Mon Sep 17 00:00:00 2001 From: Chris L Date: Wed, 17 Apr 2024 19:31:37 -0600 Subject: [PATCH 02/11] add external users --- .../entities/PteroApplication.java | 31 ++++++++++++++++++- .../entities/impl/PteroApplicationImpl.java | 7 +++++ .../pterodactyl4j/requests/Route.java | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index 7f33649..739508b 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -76,6 +76,22 @@ default PteroAction retrieveUserById(long id) { return retrieveUserById(Long.toUnsignedString(id)); } + /** + * Retrieves an individual ApplicationUser represented by the provided External ID from Pterodactyl instance + *
This requires an Application API key with the Users permission with Read access. + * + * @param id + * The user External ID + * + * @throws com.mattmalec.pterodactyl4j.exceptions.LoginException + * If the API key is incorrect or doesn't have the required permissions + * + * @throws com.mattmalec.pterodactyl4j.exceptions.NotFoundException + * If the user cannot be found + * + * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationUser ApplicationUsers} + */ + PteroAction retrieveUserByExternalId(String id); /** * Retrieves ApplicationUsers matching the provided username from Pterodactyl instance *
This requires an Application API key with the Users permission with Read access. @@ -538,6 +554,20 @@ default PteroAction retrieveServerById(long id) { return retrieveServerById(Long.toUnsignedString(id)); } + /** + * Retrieves ApplicationServers matching the provided External ID from Pterodactyl instance + *
This requires an Application API key with the Servers permission with Read access. + * + * @param id + * The External ID + * + * @throws com.mattmalec.pterodactyl4j.exceptions.LoginException + * If the API key is incorrect or doesn't have the required permissions + * + * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link java.util.List List} of {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationServer ApplicationServers} + */ + PteroAction retrieveServerByExternalId(String id); + /** * Retrieves ApplicationServers matching the provided name from Pterodactyl instance *
This requires an Application API key with the Servers permission with Read access. @@ -553,7 +583,6 @@ default PteroAction retrieveServerById(long id) { * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link java.util.List List} of {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationServer ApplicationServers} */ - PteroAction retrieveServerByExternalId(String id); PteroAction> retrieveServersByName(String name, boolean caseSensitive); diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java index 3e5019f..26cde8a 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/PteroApplicationImpl.java @@ -53,6 +53,13 @@ public PteroAction retrieveUserById(String id) { (response, request) -> new ApplicationUserImpl(response.getObject(), this)); } + public PteroAction retrieveUserByExternalId(String id) { + return PteroActionImpl.onRequestExecute( + api, + Route.Users.GET_USER_EXTERNAL.compile(id), + (response, request) -> new ApplicationUserImpl(response.getObject(), this)); + } + @Override public PaginationAction retrieveUsers() { return PaginationResponseImpl.onPagination( diff --git a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java index ca03762..68a56af 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java @@ -29,6 +29,7 @@ public static class Users { public static final Route LIST_USERS = new Route(GET, APPLICATION_PREFIX + "users?include=servers"); public static final Route GET_USER = new Route(GET, APPLICATION_PREFIX + "users/{user_id}?include=servers"); + public static final Route GET_USER_EXTERNAL = new Route(GET, APPLICATION_PREFIX + "users/external/{external_id}"); public static final Route CREATE_USER = new Route(POST, APPLICATION_PREFIX + "users"); public static final Route EDIT_USER = new Route(PATCH, APPLICATION_PREFIX + "users/{user_id}"); public static final Route DELETE_USER = new Route(DELETE, APPLICATION_PREFIX + "users/{user_id}"); From caf0555f3bb3bcd60d1ad31cc5fd9b6cc4d41c9a Mon Sep 17 00:00:00 2001 From: Chris L Date: Wed, 17 Apr 2024 19:46:13 -0600 Subject: [PATCH 03/11] i might be stupid --- .../application/entities/PteroApplication.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index 739508b..f696664 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -555,16 +555,19 @@ default PteroAction retrieveServerById(long id) { } /** - * Retrieves ApplicationServers matching the provided External ID from Pterodactyl instance + * Retrieves an individual ApplicationServer represented by the provided External ID from Pterodactyl instance *
This requires an Application API key with the Servers permission with Read access. * * @param id - * The External ID + * The id * * @throws com.mattmalec.pterodactyl4j.exceptions.LoginException * If the API key is incorrect or doesn't have the required permissions * - * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link java.util.List List} of {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationServer ApplicationServers} + * @throws com.mattmalec.pterodactyl4j.exceptions.NotFoundException + * If the server cannot be found + * + * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationServer ApplicationServer} */ PteroAction retrieveServerByExternalId(String id); @@ -582,8 +585,6 @@ default PteroAction retrieveServerById(long id) { * * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link java.util.List List} of {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationServer ApplicationServers} */ - - PteroAction> retrieveServersByName(String name, boolean caseSensitive); /** From 1b87bf164c40871b65c13c7c2bb6fc75137a0f22 Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:26:54 -0600 Subject: [PATCH 04/11] Update src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java Co-authored-by: Matt Malec --- src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java index 68a56af..83e80fa 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java @@ -75,7 +75,7 @@ public static class Servers { APPLICATION_PREFIX + "servers/{server_id}?include=allocations,user,subusers,nest,egg,location,node,databases"); public static final Route GET_SERVER_EXTERNAL = - new Route(GET, APPLICATION_PREFIX + "servers/external/{external_id}" ); + new Route(GET, APPLICATION_PREFIX + "servers/external/{external_id}?include=allocations,user,subusers,nest,egg,location,node,databases" ); public static final Route UPDATE_SERVER_DETAILS = new Route(PATCH, APPLICATION_PREFIX + "servers/{server_id}/details"); public static final Route UPDATE_SERVER_BUILD = From a3b9c450ef8e3a5d0585c31f311d33af4f25663e Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:27:01 -0600 Subject: [PATCH 05/11] Update src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java Co-authored-by: Matt Malec --- src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java index 83e80fa..17bc385 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java @@ -29,7 +29,7 @@ public static class Users { public static final Route LIST_USERS = new Route(GET, APPLICATION_PREFIX + "users?include=servers"); public static final Route GET_USER = new Route(GET, APPLICATION_PREFIX + "users/{user_id}?include=servers"); - public static final Route GET_USER_EXTERNAL = new Route(GET, APPLICATION_PREFIX + "users/external/{external_id}"); + public static final Route GET_USER_EXTERNAL = new Route(GET, APPLICATION_PREFIX + "users/external/{external_id}?includes=servers"); public static final Route CREATE_USER = new Route(POST, APPLICATION_PREFIX + "users"); public static final Route EDIT_USER = new Route(PATCH, APPLICATION_PREFIX + "users/{user_id}"); public static final Route DELETE_USER = new Route(DELETE, APPLICATION_PREFIX + "users/{user_id}"); From d3367e054366d4570ef9acd182502e8d84f659cb Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:27:08 -0600 Subject: [PATCH 06/11] Update src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java Co-authored-by: Matt Malec --- .../pterodactyl4j/application/entities/PteroApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index f696664..d8d5f41 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -565,7 +565,7 @@ default PteroAction retrieveServerById(long id) { * If the API key is incorrect or doesn't have the required permissions * * @throws com.mattmalec.pterodactyl4j.exceptions.NotFoundException - * If the server cannot be found + * If the server cannot be found * * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationServer ApplicationServer} */ From 667c1c82a95e62a34f96744a34ce1987f672730e Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:27:14 -0600 Subject: [PATCH 07/11] Update src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java Co-authored-by: Matt Malec --- .../pterodactyl4j/application/entities/PteroApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index d8d5f41..48c70c3 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -559,7 +559,7 @@ default PteroAction retrieveServerById(long id) { *
This requires an Application API key with the Servers permission with Read access. * * @param id - * The id + * The server's external ID * * @throws com.mattmalec.pterodactyl4j.exceptions.LoginException * If the API key is incorrect or doesn't have the required permissions From 37ce7c524331b9498b96469d38416373e3d1d56e Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:27:19 -0600 Subject: [PATCH 08/11] Update src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java Co-authored-by: Matt Malec --- .../pterodactyl4j/application/entities/PteroApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index 48c70c3..cd2337a 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -89,7 +89,7 @@ default PteroAction retrieveUserById(long id) { * @throws com.mattmalec.pterodactyl4j.exceptions.NotFoundException * If the user cannot be found * - * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationUser ApplicationUsers} + * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationUser ApplicationUser} */ PteroAction retrieveUserByExternalId(String id); /** From 3168689a06a2fdb175189a6622a30e955648bd3b Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:27:23 -0600 Subject: [PATCH 09/11] Update src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java Co-authored-by: Matt Malec --- .../pterodactyl4j/application/entities/PteroApplication.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index cd2337a..bbc1422 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -92,6 +92,7 @@ default PteroAction retrieveUserById(long id) { * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationUser ApplicationUser} */ PteroAction retrieveUserByExternalId(String id); + /** * Retrieves ApplicationUsers matching the provided username from Pterodactyl instance *
This requires an Application API key with the Users permission with Read access. From 15bad94a2b1e7b69ce8cb66309b0e0916be8d08c Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:27:33 -0600 Subject: [PATCH 10/11] Update src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java Co-authored-by: Matt Malec --- .../pterodactyl4j/application/entities/PteroApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index bbc1422..5acb467 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -87,7 +87,7 @@ default PteroAction retrieveUserById(long id) { * If the API key is incorrect or doesn't have the required permissions * * @throws com.mattmalec.pterodactyl4j.exceptions.NotFoundException - * If the user cannot be found + * If the user cannot be found * * @return {@link com.mattmalec.pterodactyl4j.PteroAction PteroAction} - Type {@link com.mattmalec.pterodactyl4j.application.entities.ApplicationUser ApplicationUser} */ From 8488ae1c128e0c21b0ebd6dfebd557bb347e25cd Mon Sep 17 00:00:00 2001 From: expxx Date: Thu, 18 Apr 2024 17:27:44 -0600 Subject: [PATCH 11/11] Update src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java Co-authored-by: Matt Malec --- .../pterodactyl4j/application/entities/PteroApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java index 5acb467..9eccd5f 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/PteroApplication.java @@ -81,7 +81,7 @@ default PteroAction retrieveUserById(long id) { *
This requires an Application API key with the Users permission with Read access. * * @param id - * The user External ID + * The user's external ID * * @throws com.mattmalec.pterodactyl4j.exceptions.LoginException * If the API key is incorrect or doesn't have the required permissions