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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ca4971177cb2794426ad3ae05d420f1fdbda78717fc4d881380f367b6d820c6
4
- data.tar.gz: 796de6d0afa84b5e176f188c17ec92043cfa55794755b6ab3daa744aea826f86
3
+ metadata.gz: 3a4f87a7e7c93fa4a82609673f1f8e2d83838a4a66204aaff72c9bf4009dcaf6
4
+ data.tar.gz: b9c12122bab2c4d6dabfa8d3edefcd60e863d082238c0e456c50dd86ef15ce27
5
5
  SHA512:
6
- metadata.gz: 05c2aca42fb85b2e09499664fa02fe6ac597ad2b2388f374b50bc3b8fa431871d8f0526b20e371ff55758bf6b4b7b4e57eac004c401f04521ed67c92100d1ae4
7
- data.tar.gz: 9d433ae007765e5c3c7eccbfdeaa5aca086c21e0dd1fc5a9700ac4357c2393edec4f18d47474f4383f492c0e352dff99fa2038d66f9326b63272e4b6b15d4d8f
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
  [![Gem Version](https://badge.fury.io/rb/lm_rest.svg)](https://badge.fury.io/rb/lm_rest)
6
6
 
7
- [LM Swagger API Docs](https://www.logicmonitor.com/swagger-ui-master/dist/)
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 the `api.json` file and its associated defined
51
- methods are supported. You can easily add your own if you can't wait for me
52
- to update this.
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
- for each resource. Each method name follows the pattern `method_resource`.
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_*` will return an `LMRest::Resource` object.
58
- It is essentially just a PORO with dynamically created property accessors
59
- (constructed from the API JSON response). This makes it easy to access
60
- attributes, edit them, and update objects. You can get a `Hash` version of the
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
- Note: This library handles pagination for you! Use `size` and `offset` request
64
- parameters and get sane results. Default `size` is the total number of existing
65
- objects. The default `offset` is 0.
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 array of Resource objects
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