Class: OpenObserve::Resource
- Inherits:
-
Object
- Object
- OpenObserve::Resource
- 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
apihop — every/api/...route lands on the transport'sApiclass rather than on a per-resource sub-client, because sub-clients follow URL segments, not tags; - the missing accessors —
Api::Alerts,Api::V2,Api::Streamsand 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.
Direct Known Subclasses
Alerts, Dashboards, Destinations, Incidents, Search, Sourcemaps, Streams, Templates
Constant Summary collapse
- AUTH =
The only security scheme OpenObserve operations actually reference — its OpenAPI document declares
BasicAuthwithout a single operation using it. ['Authorization'].freeze
Instance Method Summary collapse
-
#initialize(client) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(client) ⇒ Resource
Returns a new instance of Resource.
33 34 35 36 37 |
# File 'lib/openobserve/resource.rb', line 33 def initialize(client) @client = client @subs = {} @api = nil end |