Class: Infrawrench::AlertRulesNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.alert_rules

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ AlertRulesNamespace

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

Parameters:



1171
1172
1173
1174
# File 'lib/infrawrench/client.rb', line 1171

def initialize(transport)
  @transport = transport
  @deliveries = AlertRulesDeliveriesNamespace.new(@transport)
end

Instance Attribute Details

#deliveriesAlertRulesDeliveriesNamespace (readonly)

Returns client.alert_rules.deliveries.

Returns:



1167
1168
1169
# File 'lib/infrawrench/client.rb', line 1167

def deliveries
  @deliveries
end

Instance Method Details

#adopt_defaults(org_id: nil, request_options: nil) ⇒ Hash

Persist the default rule so it can be edited

A no-op when the organization already has rules.

POST /api/org/orgId/alert-rules/adopt-defaults

Raises on 403: Forbidden

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



1189
1190
1191
1192
1193
1194
1195
1196
# File 'lib/infrawrench/client.rb', line 1189

def adopt_defaults(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/alert-rules/adopt-defaults",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#get(org_id: nil, request_options: nil) ⇒ Hash

Get the organization's alert routing rules

Returns the rules in evaluation order, plus the channels and accounts a rule can name so a client can render destinations by name. An organization that has saved no rules gets the synthesized default with usingDefaults: true.

GET /api/org/orgId/alert-rules

Raises on 403: Forbidden

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as AlertRulesResponse — see sig/infrawrench/sdk.rbs.

Raises:



1215
1216
1217
1218
1219
1220
1221
1222
# File 'lib/infrawrench/client.rb', line 1215

def get(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/alert-rules",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#update(org_id: nil, body: nil, request_options: nil) ⇒ Hash

Replace the organization's alert routing rules

Whole-list replacement in one transaction. Order is part of the meaning — a rule is only correct relative to the ones above it — so a reorder applied as several requests would leave a window in which alerts route somewhere nobody asked for. Positions are re-derived from array order.

PUT /api/org/orgId/alert-rules

Raises on 400: Bad request

Raises on 403: Forbidden

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as Hash.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • body: ({ "rules" => Array[alert_rule_input] }, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



1243
1244
1245
1246
1247
1248
1249
1250
1251
# File 'lib/infrawrench/client.rb', line 1243

def update(org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "PUT",
    path: "/api/org/{orgId}/alert-rules",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end