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.
HTTP请求操作的实用工具类。 提供与UltiPanel API服务器通信的方法。 此类处理身份验证、服务器注册和服务器更新。
HTTP请求操作的实用工具类。 提供与UltiPanel API服务器通信的方法。 此类处理身份验证、服务器注册和服务器更新。
- 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).
API服务器的基础URL(延迟初始化)。 -
customBaseUrl
Custom base URL for testing purposes.
用于测试的自定义基础URL。
-
-
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.
获取API调用的基础URL。 使用延迟初始化以避免在类加载时需要UltiTools。- Returns:
- the base URL
-
setBaseUrlForTesting
Set a custom base URL for testing purposes. This should only be used in unit tests.
设置自定义的基础URL,仅用于测试目的。- 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.
重置基础URL以强制重新初始化,仅用于测试目的。 -
getServerByUUID
Get server information by UUID from the API server.
通过UUID从API服务器获取服务器信息。- Parameters:
uuid- the unique identifier of the server
服务器的唯一标识符token- the authentication token
身份验证令牌- Returns:
- HttpResponse containing the server information
包含服务器信息的HttpResponse
-
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.
向API服务器注册新服务器。- Parameters:
uuid- the unique identifier for the server
服务器的唯一标识符name- the display name for the server
服务器的显示名称port- the port number of the server
服务器的端口号domain- the domain name of the server
服务器的域名ssl- whether SSL is enabled
是否启用SSLtoken- the authentication token
身份验证令牌- Returns:
- HttpResponse containing the registration result
包含注册结果的HttpResponse
-
updateServer
protected static SimpleHttpClient.Response updateServer(String uuid, int port, String domain, boolean ssl, TokenEntity token) Update an existing server on the API server.
在API服务器上更新现有服务器。- Parameters:
uuid- the unique identifier of the server
服务器的唯一标识符port- the new port number
新的端口号domain- the new domain name
新的域名ssl- whether SSL is enabled
是否启用SSLtoken- the authentication token
身份验证令牌- Returns:
- HttpResponse containing the update result
包含更新结果的HttpResponse
-