Package com.ngrok
Class DefaultNgrokApiClient
java.lang.Object
com.ngrok.DefaultNgrokApiClient
- All Implemented Interfaces:
NgrokApiClient
Default implementation of
NgrokApiClient
based on the Armeria HTTP client.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder class for the default API client.Nested classes/interfaces inherited from interface com.ngrok.NgrokApiClient
NgrokApiClient.HttpMethod
-
Field Summary
Fields inherited from interface com.ngrok.NgrokApiClient
DEFAULT_BASE_URI
-
Method Summary
Modifier and TypeMethodDescriptionnewBuilder
(String apiKey) Creates a new ngrok API client builder.static com.linecorp.armeria.client.WebClient
Creates a new default ArmeriaWebClient
.<O> CompletionStage<O>
sendRequest
(NgrokApiClient.HttpMethod method, String endpoint, Stream<Map.Entry<String, Optional<Object>>> queryParams, Stream<Map.Entry<String, Optional<Object>>> bodyParamsStream, Optional<Class<O>> responseClass) Sends a request to the ngrok API.<O> CompletionStage<O>
sendRequest
(URI uri, Class<O> responseClass) Sends a GET request directly to the specified URI.
-
Method Details
-
newBuilder
Creates a new ngrok API client builder.- Parameters:
apiKey
- API key used to access the ngrok API- Returns:
- a client builder
-
newDefaultHttpClient
public static com.linecorp.armeria.client.WebClient newDefaultHttpClient()Creates a new default ArmeriaWebClient
.- Returns:
- a http client
-
sendRequest
Sends a GET request directly to the specified URI.- Specified by:
sendRequest
in interfaceNgrokApiClient
- Type Parameters:
O
- the return type for the API response- Parameters:
uri
- a URI to send the request toresponseClass
- the type of a Jackson-annotated POJO representing the HTTP response body- Returns:
- a future encapsulating the response type
-
sendRequest
public <O> CompletionStage<O> sendRequest(NgrokApiClient.HttpMethod method, String endpoint, Stream<Map.Entry<String, Optional<Object>>> queryParams, Stream<Map.Entry<String, Optional<Object>>> bodyParamsStream, Optional<Class<O>> responseClass) Sends a request to the ngrok API.- Specified by:
sendRequest
in interfaceNgrokApiClient
- Type Parameters:
O
- the return type for the API response- Parameters:
method
- the HTTP method to useendpoint
- the endpoint (under the base URI) to send the request toqueryParams
- any query parameters to send along with the request (parameters with an empty value will not be sent)bodyParamsStream
- any JSON body parameters to send along withthe request (parameters with an empty value will not be sent). If this stream is empty, no body should be sent.responseClass
- an optional type for a Jackson-annotated POJO representing the HTTP response body- Returns:
- a future encapsulating the response type (will be
Void
for empty responses)
-