Class: Infrawrench::PagesNamespace

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

Overview

client.pages

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ PagesNamespace

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

Parameters:



2111
2112
2113
# File 'lib/infrawrench/client.rb', line 2111

def initialize(transport)
  @transport = transport
end

Instance Method Details

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

Raise an alert to the organization's on-call transports

Fans an alert out over whatever the org has configured — Twilio SMS (and voice on request), mobile push, Slack channels, and Microsoft Teams webhooks — honouring each recipient's opt-ins. This is the same alert a workflow raises with infra.page(...), for code that runs somewhere Infrawrench does not: a health check, a deploy script, a cron on a box.

Repeat pages under the same (source, key) are suppressed, not rejected: a monitor that fires every minute pages once and then gets 200 with suppressed: true and the retryAt at which the key can page again. A page that reached nobody does not start a cooldown, so the next call tries again.

Recipients opt in per channel under the same setting that covers workflow pages.

Requires permission: pages:write.

POST /api/org/orgId/pages

Raises on 400: Bad request

Parameters:

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

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

  • body (Hash)

    Request body, shaped as PageRequest.

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

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

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

Returns:

  • (Hash)

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

Raises:



2144
2145
2146
2147
2148
2149
2150
2151
2152
# File 'lib/infrawrench/client.rb', line 2144

def create(body:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/pages",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end

#delete(source:, org_id: nil, key: nil, request_options: nil) ⇒ Hash

Clear a page key's cooldown

Drops the cooldown for one (source, key) so the next page under it delivers immediately. Call it when the condition you alerted on recovers — the workflow equivalent is infra.page.clear(key). Clearing a key that was never paged is not an error.

Requires permission: pages:write.

DELETE /api/org/orgId/pages

Raises on 400: Bad request

Parameters:

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

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

  • source (String)

    Stable name for the system raising the page: letters, digits, ., _ and -. It is the notification's sender, and it scopes the cooldown — two services paging under the same key never throttle each other.

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

    Defaults to default.

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

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

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

Returns:

  • (Hash)

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

Raises:



2176
2177
2178
2179
2180
2181
2182
2183
2184
# File 'lib/infrawrench/client.rb', line 2176

def delete(source:, org_id: nil, key: nil, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/org/{orgId}/pages",
    path_params: { "orgId" => org_id },
    query: { "source" => source, "key" => key },
    request_options: request_options
  )
end