Class NightfallClient.Builder

java.lang.Object
ai.nightfall.scan.NightfallClient.Builder
Enclosing class:
NightfallClient

public static class NightfallClient.Builder extends Object
A builder class that configures, validates, then creates instances of a Nightfall Client.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • defaultClient

      public static NightfallClient defaultClient()
      Builds and returns the client with all default values. The API key is loaded from the environment variable NIGHTFALL_API_KEY. The underlying client manages an HTTP connection pool, so instantiating more than one Nightfall client is not necessary.
      Returns:
      a Nightfall client
      Throws:
      IllegalArgumentException - if no value is set for the API key
    • withAPIKey

      public NightfallClient.Builder withAPIKey(String apiKey)
      Sets the API key for the Nightfall Client.
      Parameters:
      apiKey - a valid Nightfall API key
      Returns:
      the builder
    • withFileUploadConcurrency

      public NightfallClient.Builder withFileUploadConcurrency(int concurrency)
      Sets the concurrency for file upload operations. This field represents the number of HTTP requests that may execute in parallel when uploading file bytes. Be cognizant of your HTTP connection pool settings when deciding on a value in order to optimize your upload bandwidth. Valid values are in the range [1, 100], inclusive. Defaults to 1 if unset.
      Parameters:
      concurrency - an integer in the range [1, 100]
      Returns:
      the builder
      Throws:
      IllegalArgumentException - if the argument falls outside the allowed range
    • withConnectionTimeout

      public NightfallClient.Builder withConnectionTimeout(Duration connectionTimeout)
      Sets the connection timeout for the underlying HTTP client. If unset, defaults to 10 seconds. If set to 0, connections will not time out.
      Parameters:
      connectionTimeout - a non-negative duration less than or equal to 60 seconds
      Returns:
      the builder
      Throws:
      IllegalArgumentException - if the argument falls outside the allowed range
    • withReadTimeout

      public NightfallClient.Builder withReadTimeout(Duration readTimeout)
      Sets the read timeout for the underlying HTTP client. If unset, defaults to 30 seconds. If set to 0, reads will not time out.
      Parameters:
      readTimeout - a non-negative duration less than or equal to 120 seconds
      Returns:
      the builder
      Throws:
      IllegalArgumentException - if the argument falls outside the allowed range
    • withWriteTimeout

      public NightfallClient.Builder withWriteTimeout(Duration writeTimeout)
      Sets the write timeout for the underlying HTTP client. If unset, defaults to 60 seconds. If set to 0, writes will not time out.
      Parameters:
      writeTimeout - a non-negative duration less than or equal to 120 seconds
      Returns:
      the builder
      Throws:
      IllegalArgumentException - if the argument falls outside the allowed range
    • withMaxIdleConnections

      public NightfallClient.Builder withMaxIdleConnections(int maxIdleConnections)
      Sets the maximum number of idle connections in the underlying HTTP client. Be sure this value cooperates with the configuration for fileUploadConcurrency. If unset, defaults to 100.
      Parameters:
      maxIdleConnections - an integer in the range [1, 500]
      Returns:
      the builder
      Throws:
      IllegalArgumentException - if the argument falls outside the allowed range
    • withKeepAliveDuration

      public NightfallClient.Builder withKeepAliveDuration(Duration keepAliveDuration)
      Sets the keep-alive duration for a connection in the underlying HTTP connection pool. If unset, defaults to 30 seconds.
      Parameters:
      keepAliveDuration - a positive duration less than or equal to 120 seconds
      Returns:
      the builder
      Throws:
      IllegalArgumentException - if the argument falls outside the allowed range
    • build

      public NightfallClient build()
      Builds the client using the configured values, falling back on defaults if any values were not explicitly set.
      Returns:
      a Nightfall client
      Throws:
      IllegalArgumentException - if the API key was not set