Class: Riveter::Resources::Monitors
- Inherits:
-
Object
- Object
- Riveter::Resources::Monitors
- Defined in:
- lib/riveter/resources.rb
Overview
Scheduled enrichment runs with webhooks.
Instance Method Summary collapse
-
#create(**params) ⇒ Object
Create a monitor that re-runs an enrichment on a schedule.
-
#get(monitor_id) ⇒ Object
The monitor's schedule, webhook, and next run time.
-
#initialize(client) ⇒ Monitors
constructor
A new instance of Monitors.
-
#list ⇒ Object
List the account's monitors, newest first.
-
#runs(monitor_id, **params) ⇒ Object
The monitor's run history, newest first.
-
#update(monitor_id, **params) ⇒ Object
Pause, resume, or repoint a monitor.
Constructor Details
#initialize(client) ⇒ Monitors
Returns a new instance of Monitors.
141 142 143 |
# File 'lib/riveter/resources.rb', line 141 def initialize(client) @client = client end |
Instance Method Details
#create(**params) ⇒ Object
Create a monitor that re-runs an enrichment on a schedule. (operationId: createMonitor)
146 147 148 |
# File 'lib/riveter/resources.rb', line 146 def create(**params) Monitor.new(@client.request(:post, "/monitors", body: params)) end |
#get(monitor_id) ⇒ Object
The monitor's schedule, webhook, and next run time. (operationId: getMonitor)
157 158 159 |
# File 'lib/riveter/resources.rb', line 157 def get(monitor_id) Monitor.new(@client.request(:get, "/monitors/#{monitor_id}")) end |
#list ⇒ Object
List the account's monitors, newest first. (operationId: listMonitors)
151 152 153 154 |
# File 'lib/riveter/resources.rb', line 151 def list response = @client.request(:get, "/monitors") (response["monitors"] || []).map { |item| Monitor.new(item) } end |
#runs(monitor_id, **params) ⇒ Object
The monitor's run history, newest first. (operationId: listMonitorRuns)
167 168 169 170 171 172 |
# File 'lib/riveter/resources.rb', line 167 def runs(monitor_id, **params) fetch_page = lambda do |page| @client.request(:get, "/monitors/#{monitor_id}/runs", query: params.merge(page: page)) end RunsPage.new(fetch_page.call(params[:page] || 1), fetch_page) end |