Package com.ultikits.ultitools.utils
Class HttpRequestUtils
java.lang.Object
com.ultikits.ultitools.utils.HttpRequestUtils
Utility class for HTTP request operations.
Provides methods for communicating with the UltiPanel API server.
This class handles authentication, server registration, and server updates.
- Since:
- 6.0.0
- Author:
- wisdomme
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringGet the base URL for API calls.protected static SimpleHttpClient.ResponsegetServerByUUID(String uuid, TokenEntity token) Get server information by UUID from the API server.protected static SimpleHttpClient.ResponseregisterServer(String uuid, String name, int port, String domain, boolean ssl, TokenEntity token) Register a new server with the API server.(package private) static voidReset the base URL to force re-initialization.(package private) static voidSet a custom base URL for testing purposes.protected static SimpleHttpClient.ResponseupdateServer(String uuid, int port, String domain, boolean ssl, TokenEntity token) Update an existing server on the API server.
-
Field Details
-
baseUrl
Base URL for the API server (lazy initialized). -
customBaseUrl
Custom base URL for testing purposes.
-
-
Constructor Details
-
HttpRequestUtils
public HttpRequestUtils()
-
-
Method Details
-
getBaseUrl
Get the base URL for API calls. Uses lazy initialization to avoid requiring UltiTools at class loading time.- Returns:
- the base URL
-
setBaseUrlForTesting
Set a custom base URL for testing purposes. This should only be used in unit tests.- Parameters:
url- the custom base URL, or null to reset to default
-
resetBaseUrl
static void resetBaseUrl()Reset the base URL to force re-initialization. This should only be used in unit tests. -
getServerByUUID
Get server information by UUID from the API server.- Parameters:
uuid- the unique identifier of the servertoken- the authentication token- Returns:
- HttpResponse containing the server information
-
registerServer
protected static SimpleHttpClient.Response registerServer(String uuid, String name, int port, String domain, boolean ssl, TokenEntity token) Register a new server with the API server.- Parameters:
uuid- the unique identifier for the servername- the display name for the serverport- the port number of the serverdomain- the domain name of the serverssl- whether SSL is enabledtoken- the authentication token- Returns:
- HttpResponse containing the registration result
-
updateServer
protected static SimpleHttpClient.Response updateServer(String uuid, int port, String domain, boolean ssl, TokenEntity token) Update an existing server on the API server.- Parameters:
uuid- the unique identifier of the serverport- the new port numberdomain- the new domain namessl- whether SSL is enabledtoken- the authentication token- Returns:
- HttpResponse containing the update result
-