watchfor 0.15.0 → 0.16.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 +4 -4
- data/README.md +11 -1
- data/exe/watchfor +2 -1
- data/lib/watchfor/client.rb +11 -1
- data/lib/watchfor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3af4a4c0ee9b7d5b20fc4873a6710d37cc3d4c2d5197ff8a41fc108bc5c1bd38
|
|
4
|
+
data.tar.gz: 4ca5dea1cb43c7f1a2afc51c0eaf05048e1f5fd2db6f2545b4ebcc7d822e227b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ff5740ebc2e684b7aace9f419e0801b6e01d03c1770202a4670361023818c64ae2c43fbdb76787bffc714999411f6be30d7c765daaee73300ce04f1e9573a1e
|
|
7
|
+
data.tar.gz: 90f73616551e75ddf5e0093653609cd3375f7445d3bd1880b0159d0981cfd1947051037e908765feaa75bb7a2489cf2352a20cb150666fec3ed7c2727ca8ca0d
|
data/README.md
CHANGED
|
@@ -113,7 +113,7 @@ Runs need a `write` key (a probe sends real traffic from WatchFor's IPs)
|
|
|
113
113
|
and spend the same per-plan hourly allowance as the dashboard Toolbox.
|
|
114
114
|
Details: <https://watchfor.io/docs/api/diagnostics>
|
|
115
115
|
|
|
116
|
-
Namespaces: `wf.monitors`, `wf.alert_rules`, `wf.incidents`,
|
|
116
|
+
Namespaces: `wf.organizations`, `wf.monitors`, `wf.alert_rules`, `wf.incidents`,
|
|
117
117
|
`wf.hosts`, `wf.status_pages`, `wf.on_call`, `wf.notification_channels`, `wf.maintenance_windows`, `wf.contacts`, `wf.contact_groups`,
|
|
118
118
|
`wf.diagnostics`, `wf.playwright`, `wf.variables`. Top-level:
|
|
119
119
|
`wf.summary`, `wf.plan`, `wf.me`, `wf.locations`, `wf.monitor_types`,
|
|
@@ -129,12 +129,21 @@ belongs to; choose one with `organization:` — the SDK sends it as the
|
|
|
129
129
|
`X-WatchFor-Organization` header on every request:
|
|
130
130
|
|
|
131
131
|
```ruby
|
|
132
|
+
wf = Watchfor::Client.new(api_key: oauth_access_token)
|
|
133
|
+
wf.organizations.list["data"].each do |org|
|
|
134
|
+
puts "#{org['id']} #{org['name']} #{org['role']} is_default=#{org['is_default']} is_current=#{org['is_current']}"
|
|
135
|
+
end
|
|
136
|
+
|
|
132
137
|
acme = Watchfor::Client.new(api_key: oauth_access_token, organization: "<organization-id>")
|
|
133
138
|
acme.me # {"organization" => {"id", "name", "slug"}, "scope" => ...}
|
|
134
139
|
other = acme.with_organization("<another-organization-id>") # new client, same token
|
|
135
140
|
other.monitors.list
|
|
136
141
|
```
|
|
137
142
|
|
|
143
|
+
- `organizations.list` returns the ids to use: every organization of the
|
|
144
|
+
token's user with their `role`, `is_default` (used without `organization:`)
|
|
145
|
+
and `is_current` (what this client acts on). With an API key it returns just
|
|
146
|
+
the key's own organization (`role` is `nil`).
|
|
138
147
|
- Without `organization:`, an OAuth token acts on the user's oldest owned
|
|
139
148
|
organization (else their oldest membership).
|
|
140
149
|
- The user must be a member of that organization (otherwise `403
|
|
@@ -165,6 +174,7 @@ watchfor incidents
|
|
|
165
174
|
watchfor checks <monitor_id> [--cursor <next_cursor>]
|
|
166
175
|
watchfor report --period 30d
|
|
167
176
|
watchfor me # which organization + scope
|
|
177
|
+
watchfor organizations # ids for --organization
|
|
168
178
|
|
|
169
179
|
# OAuth token: pick the organization per call or via the environment
|
|
170
180
|
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
|
data/lib/watchfor/client.rb
CHANGED
|
@@ -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}")
|
data/lib/watchfor/version.rb
CHANGED