Class: AxHub::RawDbClient
- Inherits:
-
Object
- Object
- AxHub::RawDbClient
- Defined in:
- lib/axhub_sdk/raw_db.rb
Overview
RawDbClient is the typed raw-DB read facade. Reach it via client.apps.raw_db. It wraps the generic transport (Client#request), which camelCases response keys, so the DTOs read camelCase wire keys (dataType/perPage/hasMore) and map them onto snake_case Struct fields.
Instance Method Summary collapse
-
#initialize(client) ⇒ RawDbClient
constructor
A new instance of RawDbClient.
-
#table_rows(app_id, table, per_page: nil, page: nil) ⇒ Object
Reads one page of rows from a raw DB table.
-
#tables(app_id) ⇒ Object
Lists the raw DB tables for an app, with typed column metadata.
Constructor Details
#initialize(client) ⇒ RawDbClient
Returns a new instance of RawDbClient.
19 20 21 |
# File 'lib/axhub_sdk/raw_db.rb', line 19 def initialize(client) @client = client end |
Instance Method Details
#table_rows(app_id, table, per_page: nil, page: nil) ⇒ Object
Reads one page of rows from a raw DB table. per_page/page are forwarded as query params only when set (non-nil); nil uses the backend default page size.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/axhub_sdk/raw_db.rb', line 41 def table_rows(app_id, table, per_page: nil, page: nil) raise Error.new(category: 'validation', code: 'required', message: 'appID and table are required') if app_id.nil? || app_id.empty? || table.nil? || table.empty? query = {} query['per_page'] = per_page unless per_page.nil? query['page'] = page unless page.nil? resp = @client.request('schemaGetApiV1AppsByAppIDDbTablesByTableRows', path_params: { appID: app_id, table: table }, query: query) RawDbTableRows.new( field(resp, 'rows') || [], field(resp, 'page'), field(resp, 'perPage'), field(resp, 'hasMore') ) end |
#tables(app_id) ⇒ Object
Lists the raw DB tables for an app, with typed column metadata.
F-3 empty semantics: a successful 2xx call that returns an empty array means the app genuinely has no raw DB tables (raw DB is not enabled, or it has zero tables). A 4xx authentication/permission failure raises AxHub::Error instead — so an empty array WITHOUT a raised error means "empty", not "auth failed" (resolving the ambiguity the raw response leaves).
31 32 33 34 35 36 |
# File 'lib/axhub_sdk/raw_db.rb', line 31 def tables(app_id) raise Error.new(category: 'validation', code: 'required', message: 'appID is required') if app_id.nil? || app_id.empty? resp = @client.request('schemaGetApiV1AppsByAppIDDbTables', path_params: { appID: app_id }) (field(resp, 'tables') || []).map { |t| parse_table(t) } end |