Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add external selection #80

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ default PteroAction<ApplicationUser> retrieveUserById(long id) {
return retrieveUserById(Long.toUnsignedString(id));
}

/**
* Retrieves an individual ApplicationUser represented by the provided External ID from Pterodactyl instance
* <br>This requires an <b>Application API key</b> with the <b>Users</b> permission with <b>Read</b> access.
*
* @param 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
*
* @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 ApplicationUser}
*/
PteroAction<ApplicationUser> retrieveUserByExternalId(String id);
expxx marked this conversation as resolved.
Show resolved Hide resolved

/**
* Retrieves ApplicationUsers matching the provided username from Pterodactyl instance
* <br>This requires an <b>Application API key</b> with the <b>Users</b> permission with <b>Read</b> access.
Expand Down Expand Up @@ -538,6 +555,23 @@ default PteroAction<ApplicationServer> retrieveServerById(long id) {
return retrieveServerById(Long.toUnsignedString(id));
}

/**
* Retrieves an individual ApplicationServer represented by the provided External ID from Pterodactyl instance
* <br>This requires an <b>Application API key</b> with the <b>Servers</b> permission with <b>Read</b> access.
*
* @param 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
*
* @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<ApplicationServer> retrieveServerByExternalId(String id);
expxx marked this conversation as resolved.
Show resolved Hide resolved

/**
* Retrieves ApplicationServers matching the provided name from Pterodactyl instance
* <br>This requires an <b>Application API key</b> with the <b>Servers</b> permission with <b>Read</b> access.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public PteroAction<ApplicationUser> retrieveUserById(String id) {
(response, request) -> new ApplicationUserImpl(response.getObject(), this));
}

public PteroAction<ApplicationUser> retrieveUserByExternalId(String id) {
return PteroActionImpl.onRequestExecute(
api,
Route.Users.GET_USER_EXTERNAL.compile(id),
(response, request) -> new ApplicationUserImpl(response.getObject(), this));
}

@Override
public PaginationAction<ApplicationUser> retrieveUsers() {
return PaginationResponseImpl.onPagination(
Expand Down Expand Up @@ -276,6 +283,15 @@ public PaginationAction<ApplicationServer> retrieveServers() {
api, Route.Servers.LIST_SERVERS.compile(), (object) -> new ApplicationServerImpl(this, object));
}

@Override
public PteroAction<ApplicationServer> retrieveServerByExternalId(String id) {
return PteroActionImpl.onRequestExecute(
api,
Route.Servers.GET_SERVER_EXTERNAL.compile(id),
(response, request) -> new ApplicationServerImpl(this, response.getObject())
);
}

@Override
public PteroAction<ApplicationServer> retrieveServerById(String id) {
return PteroActionImpl.onRequestExecute(
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/mattmalec/pterodactyl4j/requests/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}?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}");
Expand Down Expand Up @@ -73,6 +74,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}?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 =
Expand Down
Loading