Class: ContextDev::Resources::Monitors

Inherits:
Object
  • Object
show all
Defined in:
lib/context_dev/resources/monitors.rb,
sig/context_dev/resources/monitors.rbs

Overview

Monitor pages, sitemaps, and extracted website data for exact or semantic changes. The change.detected webhook payload is documented by the MonitorsChangeDetectedWebhookPayload schema.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Monitors

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 Monitors.

Parameters:



347
348
349
# File 'lib/context_dev/resources/monitors.rb', line 347

def initialize(client:)
  @client = client
end

Instance Method Details

#create(change_detection:, name:, schedule:, target:, mode: nil, tags: nil, webhook: nil, request_options: {}) ⇒ ContextDev::Models::MonitorCreateResponse

Some parameter documentations has been truncated, see Models::MonitorCreateParams for more details.

Creates a monitor. The request body is a union of the supported target/change detection combinations. The monitor runs immediately after creation to create its initial baseline.

Parameters:

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/context_dev/resources/monitors.rb', line 37

def create(params)
  parsed, options = ContextDev::MonitorCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "monitors",
    body: parsed,
    model: ContextDev::Models::MonitorCreateResponse,
    options: options
  )
end

#delete(monitor_id, request_options: {}) ⇒ ContextDev::Models::MonitorDeleteResponse

Delete a monitor

Parameters:

Returns:

See Also:



164
165
166
167
168
169
170
171
# File 'lib/context_dev/resources/monitors.rb', line 164

def delete(monitor_id, params = {})
  @client.request(
    method: :delete,
    path: ["monitors/%1$s", monitor_id],
    model: ContextDev::Models::MonitorDeleteResponse,
    options: params[:request_options]
  )
end

#list(change_detection_type: nil, cursor: nil, limit: nil, q: nil, search_by: nil, search_type: nil, status: nil, tag: nil, tags: nil, target_type: nil, request_options: {}) ⇒ ContextDev::Models::MonitorListResponse

Some parameter documentations has been truncated, see Models::MonitorListParams for more details.

Lists monitors for the authenticated organization. Supports free-text search (q over search_by fields, prefix or exact via search_type) plus status/type/tag filters. Results are paginated via the opaque cursor.

Parameters:

Returns:

See Also:



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/context_dev/resources/monitors.rb', line 142

def list(params = {})
  parsed, options = ContextDev::MonitorListParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "monitors",
    query: query,
    model: ContextDev::Models::MonitorListResponse,
    options: options
  )
end

#list_account_changes(change_detection_type: nil, cursor: nil, limit: nil, monitor_id: nil, since: nil, tag: nil, target_type: nil, until_: nil, request_options: {}) ⇒ ContextDev::Models::MonitorListAccountChangesResponse

Returns an account-wide feed of detected changes across monitors.

Parameters:

Returns:

See Also:



198
199
200
201
202
203
204
205
206
207
208
# File 'lib/context_dev/resources/monitors.rb', line 198

def (params = {})
  parsed, options = ContextDev::MonitorListAccountChangesParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "monitors/changes",
    query: query.transform_keys(until_: "until"),
    model: ContextDev::Models::MonitorListAccountChangesResponse,
    options: options
  )
end

#list_account_runs(cursor: nil, limit: nil, status: nil, request_options: {}) ⇒ ContextDev::Models::MonitorListAccountRunsResponse

Some parameter documentations has been truncated, see Models::MonitorListAccountRunsParams for more details.

Returns an account-wide feed of monitor runs across all monitors.

Parameters:

Returns:

See Also:



228
229
230
231
232
233
234
235
236
237
238
# File 'lib/context_dev/resources/monitors.rb', line 228

def (params = {})
  parsed, options = ContextDev::MonitorListAccountRunsParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "monitors/runs",
    query: query,
    model: ContextDev::Models::MonitorListAccountRunsResponse,
    options: options
  )
end

#list_changes(monitor_id, cursor: nil, limit: nil, since: nil, tag: nil, until_: nil, request_options: {}) ⇒ ContextDev::Models::MonitorListChangesResponse

List changes for a monitor

Parameters:

  • monitor_id (String)
  • cursor (String)
  • limit (Integer)
  • since (Time)
  • tag (String)

    Filter to items that have this tag.

  • until_ (Time)
  • request_options (ContextDev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



261
262
263
264
265
266
267
268
269
270
271
# File 'lib/context_dev/resources/monitors.rb', line 261

def list_changes(monitor_id, params = {})
  parsed, options = ContextDev::MonitorListChangesParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["monitors/%1$s/changes", monitor_id],
    query: query.transform_keys(until_: "until"),
    model: ContextDev::Models::MonitorListChangesResponse,
    options: options
  )
end

#list_runs(monitor_id, cursor: nil, limit: nil, status: nil, request_options: {}) ⇒ ContextDev::Models::MonitorListRunsResponse

Some parameter documentations has been truncated, see Models::MonitorListRunsParams for more details.

List monitor runs

Parameters:

Returns:

See Also:



293
294
295
296
297
298
299
300
301
302
303
# File 'lib/context_dev/resources/monitors.rb', line 293

def list_runs(monitor_id, params = {})
  parsed, options = ContextDev::MonitorListRunsParams.dump_request(params)
  query = ContextDev::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["monitors/%1$s/runs", monitor_id],
    query: query,
    model: ContextDev::Models::MonitorListRunsResponse,
    options: options
  )
end

#retrieve(monitor_id, request_options: {}) ⇒ ContextDev::Models::MonitorRetrieveResponse

Get a monitor

Parameters:

Returns:

See Also:



58
59
60
61
62
63
64
65
# File 'lib/context_dev/resources/monitors.rb', line 58

def retrieve(monitor_id, params = {})
  @client.request(
    method: :get,
    path: ["monitors/%1$s", monitor_id],
    model: ContextDev::Models::MonitorRetrieveResponse,
    options: params[:request_options]
  )
end

#retrieve_change(change_id, request_options: {}) ⇒ ContextDev::Models::MonitorRetrieveChangeResponse

Get a change

Parameters:

Returns:

See Also:



315
316
317
318
319
320
321
322
# File 'lib/context_dev/resources/monitors.rb', line 315

def retrieve_change(change_id, params = {})
  @client.request(
    method: :get,
    path: ["monitors/changes/%1$s", change_id],
    model: ContextDev::Models::MonitorRetrieveChangeResponse,
    options: params[:request_options]
  )
end

#run(monitor_id, request_options: {}) ⇒ ContextDev::Models::MonitorRunResponse

Triggers an immediate run of the monitor outside its normal schedule. The run is queued and processed asynchronously.

Parameters:

Returns:

See Also:



335
336
337
338
339
340
341
342
# File 'lib/context_dev/resources/monitors.rb', line 335

def run(monitor_id, params = {})
  @client.request(
    method: :post,
    path: ["monitors/%1$s/run", monitor_id],
    model: ContextDev::Models::MonitorRunResponse,
    options: params[:request_options]
  )
end

#update(monitor_id, change_detection: nil, name: nil, schedule: nil, status: nil, tags: nil, target: nil, webhook: nil, request_options: {}) ⇒ ContextDev::Models::MonitorUpdateResponse

Some parameter documentations has been truncated, see Models::MonitorUpdateParams for more details.

Updates a monitor. If target or change_detection changes, the monitor creates a new baseline. Unsupported target/change detection combinations are rejected.

Parameters:

Returns:

See Also:



97
98
99
100
101
102
103
104
105
106
# File 'lib/context_dev/resources/monitors.rb', line 97

def update(monitor_id, params = {})
  parsed, options = ContextDev::MonitorUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["monitors/%1$s", monitor_id],
    body: parsed,
    model: ContextDev::Models::MonitorUpdateResponse,
    options: options
  )
end