Class: Shipeasy::Admin::Generated::AlertsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/shipeasy_admin/api/alerts_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AlertsApi

Returns a new instance of AlertsApi.



19
20
21
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_alert_rule(create_alert_rule_request, opts = {}) ⇒ CreateAlertRuleResponse

Create an alert rule Creates a metric-threshold alert rule. name, metricId, comparator, and threshold are required; windowHours defaults to 24, severity to warn, and enabled to true. Returns 404 if metricId does not resolve, and 400 for a metric with no scalar form over a window (e.g. retention metrics) — the cron can't evaluate those. Use cases - Threshold alert — warn when an error/latency metric crosses a value over a rolling window. - Routed alert — set notify to page a specific Slack channel or on-call email instead of the project default.

Parameters:

  • create_alert_rule_request (CreateAlertRuleRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



28
29
30
31
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 28

def create_alert_rule(create_alert_rule_request, opts = {})
  data, _status_code, _headers = create_alert_rule_with_http_info(create_alert_rule_request, opts)
  data
end

#create_alert_rule_with_http_info(create_alert_rule_request, opts = {}) ⇒ Array<(CreateAlertRuleResponse, Integer, Hash)>

Create an alert rule Creates a metric-threshold alert rule. `name`, `metricId`, `comparator`, and `threshold` are required; `windowHours` defaults to `24`, `severity` to `warn`, and `enabled` to `true`. Returns `404` if `metricId` does not resolve, and `400` for a metric with no scalar form over a window (e.g. retention metrics) — the cron can't evaluate those. Use cases - Threshold alert — warn when an error/latency metric crosses a value over a rolling window. - Routed alert — set `notify` to page a specific Slack channel or on-call email instead of the project default.

Parameters:

  • create_alert_rule_request (CreateAlertRuleRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:

  • (Array<(CreateAlertRuleResponse, Integer, Hash)>)

    CreateAlertRuleResponse data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 39

def create_alert_rule_with_http_info(create_alert_rule_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AlertsApi.create_alert_rule ...'
  end
  # verify the required parameter 'create_alert_rule_request' is set
  if @api_client.config.client_side_validation && create_alert_rule_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_alert_rule_request' when calling AlertsApi.create_alert_rule"
  end
  # resource path
  local_var_path = '/api/admin/alert-rules'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_alert_rule_request)

  # return_type
  return_type = opts[:debug_return_type] || 'CreateAlertRuleResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"AlertsApi.create_alert_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AlertsApi#create_alert_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_alert_rule(id, opts = {}) ⇒ DeleteAlertRuleResponse

Delete an alert rule Deletes the alert rule. The cron stops evaluating it immediately. Use this (then create a new rule) to repoint alerting at a different metric, since metricId is immutable. Use case: Remove an alert rule that is no longer needed, or as the first half of repointing a rule at a different metric.

Parameters:

  • id (String)

    Stable opaque alert-rule id (`ar_…`) or the rule's `name`.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



99
100
101
102
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 99

def delete_alert_rule(id, opts = {})
  data, _status_code, _headers = delete_alert_rule_with_http_info(id, opts)
  data
end

#delete_alert_rule_with_http_info(id, opts = {}) ⇒ Array<(DeleteAlertRuleResponse, Integer, Hash)>

Delete an alert rule Deletes the alert rule. The cron stops evaluating it immediately. Use this (then create a new rule) to repoint alerting at a different metric, since `metricId` is immutable. Use case: Remove an alert rule that is no longer needed, or as the first half of repointing a rule at a different metric.

Parameters:

  • id (String)

    Stable opaque alert-rule id (`ar_…`) or the rule's `name`.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:

  • (Array<(DeleteAlertRuleResponse, Integer, Hash)>)

    DeleteAlertRuleResponse data, response status code and response headers



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 110

def delete_alert_rule_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AlertsApi.delete_alert_rule ...'
  end
  # resource path
  local_var_path = '/api/admin/alert-rules/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'DeleteAlertRuleResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"AlertsApi.delete_alert_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AlertsApi#delete_alert_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_alert_rules(opts = {}) ⇒ Array<ListAlertRulesResponseInner>

List alert rules Returns every alert rule in the project (not paginated). Each rule carries its bound metricId, the denormalised metricName (or null if the metric was removed), the comparator/threshold/window, severity, enabled flag, and delivery target. Use case: Audit which metrics have alerting configured — for example to confirm an on-call threshold is set before a launch.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



160
161
162
163
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 160

def list_alert_rules(opts = {})
  data, _status_code, _headers = list_alert_rules_with_http_info(opts)
  data
end

#list_alert_rules_with_http_info(opts = {}) ⇒ Array<(Array<ListAlertRulesResponseInner>, Integer, Hash)>

List alert rules Returns every alert rule in the project (not paginated). Each rule carries its bound `metricId`, the denormalised `metricName` (or `null` if the metric was removed), the comparator/threshold/window, severity, enabled flag, and delivery target. Use case: Audit which metrics have alerting configured — for example to confirm an on-call threshold is set before a launch.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 170

def list_alert_rules_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AlertsApi.list_alert_rules ...'
  end
  # resource path
  local_var_path = '/api/admin/alert-rules'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<ListAlertRulesResponseInner>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"AlertsApi.list_alert_rules",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AlertsApi#list_alert_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_slack_channels(opts = {}) ⇒ ListSlackChannelsResponse

List Slack channels List the project's connected Slack channels — used to resolve an alert rule's notification target. Use case: Populate a channel picker, or validate an alert rule's --slack-channel before saving.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



220
221
222
223
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 220

def list_slack_channels(opts = {})
  data, _status_code, _headers = list_slack_channels_with_http_info(opts)
  data
end

#list_slack_channels_with_http_info(opts = {}) ⇒ Array<(ListSlackChannelsResponse, Integer, Hash)>

List Slack channels List the project's connected Slack channels — used to resolve an alert rule's notification target. Use case: Populate a channel picker, or validate an alert rule's `--slack-channel` before saving.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:

  • (Array<(ListSlackChannelsResponse, Integer, Hash)>)

    ListSlackChannelsResponse data, response status code and response headers



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 230

def list_slack_channels_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AlertsApi.list_slack_channels ...'
  end
  # resource path
  local_var_path = '/api/admin/slack/channels'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListSlackChannelsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"AlertsApi.list_slack_channels",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AlertsApi#list_slack_channels\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_alert_rule(id, update_alert_rule_request, opts = {}) ⇒ UpdateAlertRuleResponse

Update an alert rule Partial update of a rule's tunable knobs. metricId is immutable — it is rejected by the schema (the metric also pins the aggregation), so delete + recreate to repoint a rule. Pass \"notify\": null to revert the rule's delivery target back to the project default. Use cases - Tune sensitivity — change threshold/comparator/windowHours as the metric's baseline shifts. - Pause without losing config{ \"enabled\": false } instead of deleting the rule.

Parameters:

  • id (String)

    Stable opaque alert-rule id (`ar_…`) or the rule's `name`.

  • update_alert_rule_request (UpdateAlertRuleRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:



282
283
284
285
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 282

def update_alert_rule(id, update_alert_rule_request, opts = {})
  data, _status_code, _headers = update_alert_rule_with_http_info(id, update_alert_rule_request, opts)
  data
end

#update_alert_rule_with_http_info(id, update_alert_rule_request, opts = {}) ⇒ Array<(UpdateAlertRuleResponse, Integer, Hash)>

Update an alert rule Partial update of a rule's tunable knobs. `metricId` is immutable — it is rejected by the schema (the metric also pins the aggregation), so delete + recreate to repoint a rule. Pass `&quot;notify&quot;: null` to revert the rule's delivery target back to the project default. Use cases - Tune sensitivity — change `threshold`/`comparator`/`windowHours` as the metric's baseline shifts. - Pause without losing config — `{ &quot;enabled&quot;: false }` instead of deleting the rule.

Parameters:

  • id (String)

    Stable opaque alert-rule id (`ar_…`) or the rule's `name`.

  • update_alert_rule_request (UpdateAlertRuleRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_project_id (String)

    Project the request operates on. Optional — defaults to the project the SDK key belongs to; pass it only to scope a multi-project key (the generated client sets it once from its configuration, so per-call callers never thread it).

Returns:

  • (Array<(UpdateAlertRuleResponse, Integer, Hash)>)

    UpdateAlertRuleResponse data, response status code and response headers



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/shipeasy_admin/api/alerts_api.rb', line 294

def update_alert_rule_with_http_info(id, update_alert_rule_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AlertsApi.update_alert_rule ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling AlertsApi.update_alert_rule"
  end
  # verify the required parameter 'update_alert_rule_request' is set
  if @api_client.config.client_side_validation && update_alert_rule_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_alert_rule_request' when calling AlertsApi.update_alert_rule"
  end
  # resource path
  local_var_path = '/api/admin/alert-rules/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'X-Project-Id'] = opts[:'x_project_id'] if !opts[:'x_project_id'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(update_alert_rule_request)

  # return_type
  return_type = opts[:debug_return_type] || 'UpdateAlertRuleResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerSdkKey']

  new_options = opts.merge(
    :operation => :"AlertsApi.update_alert_rule",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AlertsApi#update_alert_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end