lm_rest 1.0.6 → 1.0.7
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/.codex +0 -0
- data/README.md +29 -16
- data/api.json +12202 -439
- data/bin/ds_checker.rb +178 -161
- data/bin/graphgrab.rb +41 -0
- data/lib/lm_rest/api_client.rb +409 -170
- data/lib/lm_rest/request_params.rb +13 -5
- data/lib/lm_rest/resource.rb +68 -17
- data/lib/lm_rest/version.rb +1 -1
- data/lm_rest.gemspec +1 -0
- metadata +19 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a4f87a7e7c93fa4a82609673f1f8e2d83838a4a66204aaff72c9bf4009dcaf6
|
|
4
|
+
data.tar.gz: b9c12122bab2c4d6dabfa8d3edefcd60e863d082238c0e456c50dd86ef15ce27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b33d7e50310ea6f7a1d679f8bf4385839c3226b41830ef513ada313423aa6b2227988f40e1403e4e05be56d5d96fd51af8008a451311faec1d498ff4b990576
|
|
7
|
+
data.tar.gz: f2553bdb581abd17695a47e56aa23bf5790272a3ad57475ae42dd13b92a19a786ae404e09acecf40a43b3bd14bc4ebc8aeba11d31edbb648871a51394e399426
|
data/.codex
ADDED
|
File without changes
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ An Unofficial Ruby gem for the LogicMonitor REST API.
|
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/rb/lm_rest)
|
|
6
6
|
|
|
7
|
-
[
|
|
7
|
+
[LogicMonitor REST API v3 Swagger Docs](https://www.logicmonitor.com/support/rest-api-v3-swagger-documentation)
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -47,27 +47,32 @@ your system up even more.
|
|
|
47
47
|
|
|
48
48
|
## Supported API Resources
|
|
49
49
|
|
|
50
|
-
Every API resource is defined in
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
Every API resource and operation is defined in `api.json`, which is generated
|
|
51
|
+
from the LogicMonitor REST API v3 Swagger surface. Generated operation methods
|
|
52
|
+
and legacy convenience aliases are both supported.
|
|
53
53
|
|
|
54
|
-
Each method (`get_*, add_*, update_*, delete_*`) works the same
|
|
55
|
-
|
|
54
|
+
Each method (`get_*, add_*, update_*, delete_*`) works the same for each
|
|
55
|
+
resource. Each method name follows the pattern `method_resource`.
|
|
56
56
|
|
|
57
|
-
Every method except for `delete_*`
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
object with `#to_h`.
|
|
57
|
+
Every method except for `delete_*` returns `LMRest::Resource` objects. A
|
|
58
|
+
resource is a hash-backed wrapper around the API JSON response with dynamic
|
|
59
|
+
attribute-style access, so both `resource.name` and `resource['name']` work.
|
|
60
|
+
Use `#to_h` to get a deep-copied `Hash` version suitable for updates.
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
Paginated GET endpoints are handled automatically. If you omit `size`, the
|
|
63
|
+
client will keep requesting pages until all items have been collected. If you
|
|
64
|
+
set `size`, the client will fetch up to that many items even when it spans
|
|
65
|
+
multiple 1000-item API pages. `offset` defaults to `0`.
|
|
66
66
|
|
|
67
67
|
## Usage
|
|
68
68
|
|
|
69
69
|
See the example `ds_checker.rb` script in `bin` to get a better feel for how to
|
|
70
|
-
use the gem.
|
|
70
|
+
use the gem. It expects:
|
|
71
|
+
|
|
72
|
+
* LogicMonitor account name
|
|
73
|
+
* API access ID
|
|
74
|
+
* API access key
|
|
75
|
+
* Datasource name or filter glob
|
|
71
76
|
|
|
72
77
|
```ruby
|
|
73
78
|
require 'lm_rest'
|
|
@@ -77,7 +82,7 @@ require 'lm_rest'
|
|
|
77
82
|
|
|
78
83
|
lm = LMRest::APIClient.new('company', 'access_id', 'access_key')
|
|
79
84
|
|
|
80
|
-
# returns
|
|
85
|
+
# returns all datasource resources across every API page
|
|
81
86
|
lm.get_datasources
|
|
82
87
|
|
|
83
88
|
|
|
@@ -134,6 +139,14 @@ lm.ack_collector_down(id, comment)
|
|
|
134
139
|
lm.run_report(id)
|
|
135
140
|
|
|
136
141
|
|
|
142
|
+
# Handle API failures without leaking response bodies to stdout
|
|
143
|
+
begin
|
|
144
|
+
lm.get_device(999999)
|
|
145
|
+
rescue LMRest::APIError => e
|
|
146
|
+
warn "#{e.status}: #{e.body}"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
|
|
137
150
|
```
|
|
138
151
|
|
|
139
152
|
## TODO
|