Class: OpenObserve::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/openobserve/resource.rb

Overview

Base class for every business domain (search, streams, alerts, destinations, …).

It owns what every domain shares: reaching the raw transport, resolving the transport sub-clients, carrying the organization so no caller ever types org_id: again, and funnelling every openobserve-api failure through the single Client::Error surface.

Three transport rough edges are absorbed here:

  • the generated models — every domain but Search bypasses the generated operations entirely and issues its requests through #raw, because those operations deserialize into models that silently drop whatever the checked-in spec does not declare, and validate outgoing attributes against that same frozen list;
  • the api hop — every /api/... route lands on the transport's Api class rather than on a per-resource sub-client, because sub-clients follow URL segments, not tags;
  • the missing accessorsApi::Alerts, Api::V2, Api::Streams and their siblings are generated as classes but their parent exposes no accessor, so #sub builds them. No domain needs it now that reads and writes both go through #raw; it stays as the documented way back to a generated operation should one ever be worth using.

Note what is deliberately not absorbed: OpenObserve answers an empty list with 200 and an empty array, so #collection does not normalise 404s away. A 404 on a list means a wrong path or a missing organization, and must stay loud.

Constant Summary collapse

AUTH =

The only security scheme OpenObserve operations actually reference — its OpenAPI document declares BasicAuth without a single operation using it.

['Authorization'].freeze

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Resource

Returns a new instance of Resource.

Parameters:



33
34
35
36
37
# File 'lib/openobserve/resource.rb', line 33

def initialize(client)
  @client = client
  @subs = {}
  @api = nil
end