Record Class HttpSourceConfig

java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.source.HttpSourceConfig
Record Components:
url - the URL; may contain ${ENV_VAR} references; must not be blank
method - the HTTP method (GET, POST or QUERY — Relix is read-only); must not be null
headers - static request headers; may be empty
extract - how to locate records in the response body; absent means the JSON-file default (top-level array or object)
paginate - optional pagination parameter mapping; absent means unpaginated
columns - the ordered column specifications; may be empty, which selects an open (schema-on-read) source
body - the request body (for POST/QUERY reads, e.g. a GraphQL/search query); absent means no body
auth - an authentication shorthand; absent means none (or expressed via a raw Authorization header)
All Implemented Interfaces:
SourceConfig

public record HttpSourceConfig(String url, HttpMethod method, Map<String,String> headers, Optional<ExtractSpec> extract, Optional<PaginateSpec> paginate, List<ColumnSpec> columns, Optional<String> body, Optional<AuthSpec> auth) extends Record implements SourceConfig
Configuration for an HTTP/REST API source.

Full example:

   source current_weather from http {
       url:     "https://api.openweathermap.org/data/2.5/weather",
       method:  GET,
       headers: { "Accept": "application/json" },
       auth:    apikey("X-API-Key", "${WEATHER_API_KEY}"),
       extract: json("$.items"),
       schema: {
           temp:      NUMBER at "$.main.temp",
           condition: STRING at "$.weather[0].description"
       }
   };
 

The schema block is optional: when omitted the source is open (schema-on-read) — each record becomes a document row navigated by JSONPath at query time. When present, the source is a closed, typed relation whose columns are extracted by their at "$.path" bindings.

The extract spec is also optional: when omitted the response body is parsed as JSON and a top-level array (or single object) is treated as the records, exactly like a local JSON file source.

Header, URL, body, and auth values may contain ${VAR} placeholders. They are resolved when a query runs, from the selected environment in the command-line tool and through the resolver an embedding session was built with (Relix.Builder.placeholders), and the declaration keeps the placeholder.

  • Constructor Details

    • HttpSourceConfig

      public HttpSourceConfig(String url, HttpMethod method, Map<String,String> headers, Optional<ExtractSpec> extract, Optional<PaginateSpec> paginate, List<ColumnSpec> columns, Optional<String> body, Optional<AuthSpec> auth)
      Creates an instance of a HttpSourceConfig record class.
      Parameters:
      url - the value for the url record component
      method - the value for the method record component
      headers - the value for the headers record component
      extract - the value for the extract record component
      paginate - the value for the paginate record component
      columns - the value for the columns record component
      body - the value for the body record component
      auth - the value for the auth record component
    • HttpSourceConfig

      public HttpSourceConfig(String url, HttpMethod method, Map<String,String> headers, ExtractSpec extract, Optional<PaginateSpec> paginate, List<ColumnSpec> columns)
      Back-compatible convenience constructor with a required (non-optional) extract spec and no body/auth — retained so existing callers and fixtures compile unchanged.
      Parameters:
      url - the URL
      method - the HTTP method
      headers - static request headers
      extract - the extract spec
      paginate - optional pagination mapping
      columns - the column specifications (may be empty for an open source)
  • Method Details

    • isOpen

      public boolean isOpen()
      Returns true if this source declares no columns and is therefore an open (schema-on-read) source whose rows are navigated by JSONPath.
      Returns:
      whether the source is open
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • url

      public String url()
      Returns the value of the url record component.
      Returns:
      the value of the url record component
    • method

      public HttpMethod method()
      Returns the value of the method record component.
      Returns:
      the value of the method record component
    • headers

      public Map<String,String> headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component
    • extract

      public Optional<ExtractSpec> extract()
      Returns the value of the extract record component.
      Returns:
      the value of the extract record component
    • paginate

      public Optional<PaginateSpec> paginate()
      Returns the value of the paginate record component.
      Returns:
      the value of the paginate record component
    • columns

      public List<ColumnSpec> columns()
      Returns the value of the columns record component.
      Returns:
      the value of the columns record component
    • body

      public Optional<String> body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component
    • auth

      public Optional<AuthSpec> auth()
      Returns the value of the auth record component.
      Returns:
      the value of the auth record component