Class: Infrawrench::QueryMonitorsNamespace
- Inherits:
-
Object
- Object
- Infrawrench::QueryMonitorsNamespace
- Defined in:
- lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs
Overview
client.query_monitors
Instance Attribute Summary collapse
-
#get ⇒ QueryMonitorsGetNamespace
readonly
client.query_monitors.get.
Instance Method Summary collapse
-
#create(org_id: nil, body: nil, request_options: nil) ⇒ Hash
Create a query monitor.
-
#delete(monitor_id:, org_id: nil, request_options: nil) ⇒ nil
Delete a query monitor.
-
#initialize(transport) ⇒ QueryMonitorsNamespace
constructor
private
A new instance of QueryMonitorsNamespace.
-
#targets(org_id: nil, request_options: nil) ⇒ Hash
List what a monitor can run against.
-
#test(org_id: nil, body: nil, request_options: nil) ⇒ Hash
Run a query once without saving it.
-
#update(monitor_id:, org_id: nil, body: nil, request_options: nil) ⇒ Hash
Edit a query monitor.
Constructor Details
#initialize(transport) ⇒ QueryMonitorsNamespace
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of QueryMonitorsNamespace.
11971 11972 11973 11974 |
# File 'lib/infrawrench/client.rb', line 11971 def initialize(transport) @transport = transport @get = QueryMonitorsGetNamespace.new(@transport) end |
Instance Attribute Details
#get ⇒ QueryMonitorsGetNamespace (readonly)
Returns client.query_monitors.get.
11967 11968 11969 |
# File 'lib/infrawrench/client.rb', line 11967 def get @get end |
Instance Method Details
#create(org_id: nil, body: nil, request_options: nil) ⇒ Hash
Create a query monitor
A monitor may only run select, with, show or explain, and only a
single statement. That is a deliberate allowlist of leading keywords
rather than a denylist of dangerous ones: a denylist has to be right about
every dialect's spelling of every destructive verb, forever, and only has
to be wrong once. Comments are stripped before the check, so -- harmless\nDROP TABLE x is rejected, and SELECT 1; DROP TABLE x is
rejected by the single-statement rule.
Takes resources:execute, like the SQL editor: saving a monitor arranges
for a query to run against a customer database on a schedule, forever,
which is a strictly larger act than running one while watching it.
POST /api/org/orgId/query-monitors
Raises on 400: Bad request
Raises on 404: Not found
Raises on 409: Conflict
12004 12005 12006 12007 12008 12009 12010 12011 12012 |
# File 'lib/infrawrench/client.rb', line 12004 def create(org_id: nil, body: nil, request_options: nil) @transport.request( http_method: "POST", path: "/api/org/{orgId}/query-monitors", path_params: { "orgId" => org_id }, body: body, request_options: ) end |
#delete(monitor_id:, org_id: nil, request_options: nil) ⇒ nil
Delete a query monitor
DELETE /api/org/orgId/query-monitors/monitorId
Raises on 404: Not found
12026 12027 12028 12029 12030 12031 12032 12033 12034 |
# File 'lib/infrawrench/client.rb', line 12026 def delete(monitor_id:, org_id: nil, request_options: nil) @transport.request( http_method: "DELETE", path: "/api/org/{orgId}/query-monitors/{monitorId}", path_params: { "orgId" => org_id, "monitorId" => monitor_id }, accept: :empty, request_options: ) end |
#targets(org_id: nil, request_options: nil) ⇒ Hash
List what a monitor can run against
The editor's target picker: each account with a SQL driver of its own,
plus the SQL-capable resources inside it — a database that is a resource
(a ClickHouse service, a D1 or Turso database, a Databricks SQL warehouse,
a BigQuery dataset) rather than the account's own connection. Accounts
with neither are omitted; a monitor pointed at one could only ever fail.
Pass a resource's id (and optionally its resourceTypeId — the server
fills it from the synced resource either way) when creating a monitor to
scope the query to that resource.
GET /api/org/orgId/query-monitors/targets
12055 12056 12057 12058 12059 12060 12061 12062 |
# File 'lib/infrawrench/client.rb', line 12055 def targets(org_id: nil, request_options: nil) @transport.request( http_method: "GET", path: "/api/org/{orgId}/query-monitors/targets", path_params: { "orgId" => org_id }, request_options: ) end |
#test(org_id: nil, body: nil, request_options: nil) ⇒ Hash
Run a query once without saving it
The editor's 'try it' button. Goes through the same read-only guard as a scheduled run — a query that could not be saved as a monitor must not be runnable through the monitor's own preview — and applies the threshold, so the answer says whether it would be breaching rather than leaving the reader to compare two numbers.
POST /api/org/orgId/query-monitors/test
Raises on 400: Bad request
12083 12084 12085 12086 12087 12088 12089 12090 12091 |
# File 'lib/infrawrench/client.rb', line 12083 def test(org_id: nil, body: nil, request_options: nil) @transport.request( http_method: "POST", path: "/api/org/{orgId}/query-monitors/test", path_params: { "orgId" => org_id }, body: body, request_options: ) end |
#update(monitor_id:, org_id: nil, body: nil, request_options: nil) ⇒ Hash
Edit a query monitor
Omitted fields are left alone and the result is validated after merging. Changing the query, the mode, the operator or the threshold re-arms the monitor: the stored breach streak was accumulated against a different question, and carrying it forward would fire an alert on the first run of a rule nobody has tested.
PATCH /api/org/orgId/query-monitors/monitorId
Raises on 400: Bad request
Raises on 404: Not found
Raises on 409: Conflict
12116 12117 12118 12119 12120 12121 12122 12123 12124 |
# File 'lib/infrawrench/client.rb', line 12116 def update(monitor_id:, org_id: nil, body: nil, request_options: nil) @transport.request( http_method: "PATCH", path: "/api/org/{orgId}/query-monitors/{monitorId}", path_params: { "orgId" => org_id, "monitorId" => monitor_id }, body: body, request_options: ) end |