watchfor 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5ad40afc1187be8bcdf41c4c418b3c18b304b097a901219edfe777ae41087d1
4
- data.tar.gz: b4da046bc763240825953b51a69e13e50838272d7e642bf78f450b4f7914810d
3
+ metadata.gz: 440bd3cc9c46afea4d4952984e93294db18a02ded76d8a5d5bbaded7d8a927a5
4
+ data.tar.gz: d0798e7395d9471d562ccbe0f299c330603e20cae7141cf68c0e13db4e9acf94
5
5
  SHA512:
6
- metadata.gz: 73e41e8dc6673385ab4bfca74bb41a6e2d83d08429b88ff1bf826c835201295eda5c5b1edd76cf32518cb86ba9829b4b8d9b4641e9f1ee0f5a50743e2fe848e6
7
- data.tar.gz: 1a4951d407a131eec5206d4b909de80a26f4833aaa916a08aa914846c6f71b8b6161cb5ceb90b982c3a0a2ce91fb465d5f7c297ce7bac2db92215e3b3481160d
6
+ metadata.gz: 6b1a026e89c31b6c2bf93f405655f360bffd2a91692d15f4df0da6dda625b25f54acf3d5d5fe54dfa5f25d53bef9476233b0d222852dcc7901baa2983177f988
7
+ data.tar.gz: '0288f489a53a6029f352dad623296943e3e917bfa0cf93fec0dec6f5262ca122bc62b6b5e8869e359a4994e8639ae9b885d13a944bcfc43abac7cc156e5f9676'
data/README.md CHANGED
@@ -37,6 +37,12 @@ wf.incidents.list(status: "firing")["data"].each { |i| puts i["message"] }
37
37
  # uptime, SLA, reports and the status page (include undoes it)
38
38
  wf.incidents.exclude(19351, reason: "Probe-side DNS hiccup")
39
39
 
40
+ # Post-mortem: creates the draft on first use; only the sections you name change
41
+ wf.incidents.update_postmortem(19351, {
42
+ sections: { summary: "Checkout returned 502 for 14 minutes." },
43
+ add_action_items: [{ title: "Validate upstreams in CI" }]
44
+ })
45
+
40
46
  # Irreversible: wipe a monitor's checks and incidents; uptime restarts "since reset"
41
47
  wf.monitors.reset(mon["id"])
42
48
 
@@ -113,7 +119,7 @@ Runs need a `write` key (a probe sends real traffic from WatchFor's IPs)
113
119
  and spend the same per-plan hourly allowance as the dashboard Toolbox.
114
120
  Details: <https://watchfor.io/docs/api/diagnostics>
115
121
 
116
- Namespaces: `wf.monitors`, `wf.alert_rules`, `wf.incidents`,
122
+ Namespaces: `wf.organizations`, `wf.monitors`, `wf.alert_rules`, `wf.incidents`,
117
123
  `wf.hosts`, `wf.status_pages`, `wf.on_call`, `wf.notification_channels`, `wf.maintenance_windows`, `wf.contacts`, `wf.contact_groups`,
118
124
  `wf.diagnostics`, `wf.playwright`, `wf.variables`. Top-level:
119
125
  `wf.summary`, `wf.plan`, `wf.me`, `wf.locations`, `wf.monitor_types`,
@@ -129,12 +135,21 @@ belongs to; choose one with `organization:` — the SDK sends it as the
129
135
  `X-WatchFor-Organization` header on every request:
130
136
 
131
137
  ```ruby
138
+ wf = Watchfor::Client.new(api_key: oauth_access_token)
139
+ wf.organizations.list["data"].each do |org|
140
+ puts "#{org['id']} #{org['name']} #{org['role']} is_default=#{org['is_default']} is_current=#{org['is_current']}"
141
+ end
142
+
132
143
  acme = Watchfor::Client.new(api_key: oauth_access_token, organization: "<organization-id>")
133
144
  acme.me # {"organization" => {"id", "name", "slug"}, "scope" => ...}
134
145
  other = acme.with_organization("<another-organization-id>") # new client, same token
135
146
  other.monitors.list
136
147
  ```
137
148
 
149
+ - `organizations.list` returns the ids to use: every organization of the
150
+ token's user with their `role`, `is_default` (used without `organization:`)
151
+ and `is_current` (what this client acts on). With an API key it returns just
152
+ the key's own organization (`role` is `nil`).
138
153
  - Without `organization:`, an OAuth token acts on the user's oldest owned
139
154
  organization (else their oldest membership).
140
155
  - The user must be a member of that organization (otherwise `403
@@ -165,6 +180,7 @@ watchfor incidents
165
180
  watchfor checks <monitor_id> [--cursor <next_cursor>]
166
181
  watchfor report --period 30d
167
182
  watchfor me # which organization + scope
183
+ watchfor organizations # ids for --organization
168
184
 
169
185
  # OAuth token: pick the organization per call or via the environment
170
186
  export WATCHFOR_API_KEY=<oauth-access-token>
data/exe/watchfor CHANGED
@@ -42,6 +42,7 @@ begin
42
42
  result =
43
43
  case command
44
44
  when "me" then wf.me
45
+ when "organizations", "orgs" then wf.organizations.list
45
46
  when "summary" then wf.summary
46
47
  when "plan" then wf.plan
47
48
  when "monitors" then wf.monitors.list
@@ -60,7 +61,7 @@ begin
60
61
  exit 0
61
62
  else
62
63
  warn "Usage: watchfor [--organization <id>] " \
63
- "[me|summary|plan|monitors|locations|monitor-types|incidents|checks <monitor_id> [--cursor c]|" \
64
+ "[me|organizations|summary|plan|monitors|locations|monitor-types|incidents|checks <monitor_id> [--cursor c]|" \
64
65
  "report [--period 7d|30d]|metrics [--tag t] [--type t]]\n" \
65
66
  "Env: WATCHFOR_API_KEY (API key or OAuth access token), WATCHFOR_ORGANIZATION, WATCHFOR_BASE_URL"
66
67
  exit 2
@@ -36,7 +36,7 @@ module Watchfor
36
36
  # An API key belongs to one organization: leave +organization:+ unset, or
37
37
  # pass that same id (any other id is 403 forbidden).
38
38
  class Client
39
- attr_reader :monitors, :alert_rules, :incidents, :hosts, :status_pages, :on_call, :notification_channels,
39
+ attr_reader :organizations, :monitors, :alert_rules, :incidents, :hosts, :status_pages, :on_call, :notification_channels,
40
40
  :maintenance_windows, :contacts, :contact_groups,
41
41
  :diagnostics, :playwright, :variables, :organization
42
42
 
@@ -48,6 +48,7 @@ module Watchfor
48
48
  @timeout = timeout
49
49
  org = organization.to_s.strip
50
50
  @organization = org.empty? ? nil : org
51
+ @organizations = Organizations.new(self)
51
52
  @monitors = Monitors.new(self)
52
53
  @alert_rules = AlertRules.new(self)
53
54
  @incidents = Incidents.new(self)
@@ -268,6 +269,15 @@ module Watchfor
268
269
  def delete(name) = @c.request("DELETE", "/variables/#{name}")
269
270
  end
270
271
 
272
+ # The organizations this credential can act on: the ids +organization:+ /
273
+ # +with_organization+ accept. An OAuth token lists every organization of
274
+ # its user ("role", plus "is_default" for the one used without
275
+ # +organization:+ and "is_current" for the one the request acted on); an
276
+ # API key only its own ("role" nil).
277
+ class Organizations < Namespace
278
+ def list = @c.request("GET", "/organizations")
279
+ end
280
+
271
281
  class AlertRules < Namespace
272
282
  def list(monitor_id) = @c.request("GET", "/monitors/#{monitor_id}/alert-rules")
273
283
  def get(monitor_id, rule_id) = @c.request("GET", "/monitors/#{monitor_id}/alert-rules/#{rule_id}")
@@ -295,6 +305,13 @@ module Watchfor
295
305
  def mark_maintenance(id, idempotency_key: nil)
296
306
  @c.request("POST", "/incidents/#{id}/mark-maintenance", idempotency_key: idempotency_key)
297
307
  end
308
+ # The incident's post-mortem (404 when it has none yet - #update_postmortem creates it).
309
+ def get_postmortem(id) = @c.request("GET", "/incidents/#{id}/postmortem")
310
+ # Create the post-mortem draft on first use, then apply only what is given:
311
+ # "sections" replaces just the sections named; "add_timeline" and
312
+ # "add_action_items" append (repeats skipped). Publishing and deleting stay
313
+ # in the dashboard.
314
+ def update_postmortem(id, body) = @c.request("PATCH", "/incidents/#{id}/postmortem", body: body)
298
315
  end
299
316
 
300
317
  class StatusPages < Namespace
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Watchfor
4
- VERSION = "0.15.0"
4
+ VERSION = "0.17.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchfor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WatchFor