Package com.ngrok

Class DefaultNgrokApiClient

java.lang.Object
com.ngrok.DefaultNgrokApiClient
All Implemented Interfaces:
NgrokApiClient

public class DefaultNgrokApiClient extends Object implements NgrokApiClient
Default implementation of NgrokApiClient based on the Armeria HTTP client.
  • Method Details

    • newBuilder

      public static DefaultNgrokApiClient.Builder newBuilder(String apiKey)
      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 Armeria WebClient.
      Returns:
      a http client
    • sendRequest

      public <O> CompletionStage<O> sendRequest(URI uri, Class<O> responseClass)
      Sends a GET request directly to the specified URI.
      Specified by:
      sendRequest in interface NgrokApiClient
      Type Parameters:
      O - the return type for the API response
      Parameters:
      uri - a URI to send the request to
      responseClass - 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 interface NgrokApiClient
      Type Parameters:
      O - the return type for the API response
      Parameters:
      method - the HTTP method to use
      endpoint - the endpoint (under the base URI) to send the request to
      queryParams - 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)