lm_rest 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aa5d869b3f6a8928f4c7328c79e695ed96b3559abff1cac0daf4da09d0ad6526
4
+ data.tar.gz: 183f6cca33109ce03c90d2d43cedba9b52d54b4c93d7143e864abc44c2290760
5
+ SHA512:
6
+ metadata.gz: 220d6193ce97099a9e6af01b5eb5c2ef43cf91d580d626737ca9bf7f0954ebfe7171bb9e04797fbd23317ce75a673a221a48a825dbadc246782a7b15b154c218
7
+ data.tar.gz: 574b492b98762c1be1f41acac90039f985852cf585dc9976d7176996e86c276515d0fe75bb0b60be192b191ad08de46956542f566088d36ccdca19c627c017a8
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ group :development do
5
+ gem 'pry'
6
+ end
7
+ # Specify your gem's dependencies in lm_rest.gemspec
8
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 mikerodrigues
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # LMRest
2
+
3
+ A Ruby gem for the LogicMonitor REST API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'lm_rest'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ `$ bundle`
16
+
17
+ Or install it yourself as:
18
+
19
+ `$ gem install lm_rest`
20
+
21
+ ## Supported API Resources
22
+
23
+ Every API resource defined in the `api.json` file and its associated defined
24
+ methods are supported, and you can easily add your own if you can't wait for me
25
+ to update this.
26
+
27
+ Each method (`get_*, add_*, update_*, delete_*`) works the same
28
+ for each resource. Each method name follows the pattern `method_resource`.
29
+
30
+ Every method except for `delete_*` will return an `LMRest::Resource` object.
31
+ It is essentially just a PORO with dynamically created property accessors
32
+ (constructed from the API JSON response). This makes it easy to access
33
+ attributes, edit them, and update objects. You can get a `Hash` version of the
34
+ object with `#to_h`.
35
+
36
+ Note: This library handles pagination for you! Use `size` and `offset` request
37
+ parameters and get sane results. Default `size` is the total number of existing
38
+ objects. The default `offset` is 0.
39
+
40
+ ## Usage
41
+
42
+ See the example `ds_checker.rb` script in `bin` to get a better feel for how to
43
+ use the gem.
44
+
45
+ ```ruby
46
+ require 'lm_rest'
47
+
48
+
49
+ # Authenticate with an API token (preferred):
50
+ credential = {company: 'company',
51
+ access_key:'api_access_key',
52
+ access_id:'api_access_id'}
53
+
54
+
55
+ # Authenticate with Basic Auth (not preferred):
56
+ credential = {company: 'company',
57
+ user: 'user',
58
+ password: 'password'}
59
+
60
+ # Create an instance of the API Client
61
+ lm = LMRest::APIClient.new(credential)
62
+
63
+
64
+ # returns array of Resource objects
65
+ lm.get_datasources
66
+
67
+
68
+ # get a datasource by id
69
+ lm.get_datasource(721)
70
+
71
+
72
+ # return array of Resource objects whose names begin with "VMware"
73
+ lm.get_datasources(filter: 'name:VMware*')
74
+
75
+
76
+ # add a device to your account
77
+ lm.add_device({name: 'gibson',
78
+ displayName: 'The Gibson',
79
+ preferredCollectorId: 1,
80
+ hostGroupIds: "1,2",
81
+ description: 'Big iron, heavy metal',
82
+ customProperties: [{name: 'terminal', value: '23'}]})
83
+
84
+
85
+ # add_*, update_*, and delete_* methods accept LMRest::Resource objects:
86
+
87
+ # get a device by name
88
+ device = lm.get_devices({filter: 'name:gibson'})[0]
89
+
90
+ # change the device's name
91
+ device.name = "Gibson"
92
+
93
+ # update the device with the object
94
+ lm.update_device(device)
95
+
96
+ # delete the device with the object
97
+ lm.delete_device(device)
98
+
99
+ # add the device back
100
+ lm.add_device(device)
101
+
102
+
103
+
104
+ # Get your Santaba version info
105
+ lm.get_version
106
+
107
+
108
+ # ACK Collector Down Alerts!
109
+ #
110
+ # You can also pass an Alert Resource instead of an id but the comment is
111
+ # mandatory!
112
+
113
+ lm.ack_collector_down(id, comment)
114
+
115
+
116
+ # Run Reports!
117
+ lm.run_report(id)
118
+
119
+
120
+ ```
121
+
122
+
123
+ ## Development
124
+
125
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
126
+
127
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
128
+
129
+
130
+ ## Contributing
131
+
132
+ Bug reports and pull requests are welcome.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
data/api.json ADDED
@@ -0,0 +1,386 @@
1
+ {
2
+ "AccessLogEntry": {
3
+ "url": "/setting/accesslogs",
4
+ "method_names": {
5
+ "singular": "accesslog",
6
+ "plural": "accesslogs"
7
+ },
8
+ "actions": [
9
+ "get"
10
+ ]
11
+ },
12
+ "BatchJob": {
13
+ "url": "/setting/batchjobs",
14
+ "method_names": {
15
+ "singular": "batchjob",
16
+ "plural": "batchjobs"
17
+ },
18
+ "actions": [
19
+ "get",
20
+ "add",
21
+ "update",
22
+ "delete"
23
+ ]
24
+ },
25
+ "Collector": {
26
+ "url": "/setting/collectors",
27
+ "method_names": {
28
+ "singular": "collector",
29
+ "plural": "collectors"
30
+ },
31
+ "actions": [
32
+ "get",
33
+ "update",
34
+ "delete"
35
+ ]
36
+ },
37
+ "Datasource": {
38
+ "url": "/setting/datasources",
39
+ "method_names": {
40
+ "singular": "datasource",
41
+ "plural": "datasources"
42
+ },
43
+ "actions": [
44
+ "get",
45
+ "add",
46
+ "update",
47
+ "delete"
48
+ ],
49
+ "children": []
50
+ },
51
+ "Eventsource": {
52
+ "url": "/setting/eventsources",
53
+ "method_names": {
54
+ "singular": "eventsource",
55
+ "plural": "eventsources"
56
+ },
57
+ "actions": [
58
+ "get",
59
+ "add",
60
+ "update",
61
+ "delete"
62
+ ]
63
+ },
64
+ "Propertysource": {
65
+ "url": "/setting/propertyrules",
66
+ "method_names": {
67
+ "singular": "propertysource",
68
+ "plural": "propertysources"
69
+ },
70
+ "actions": [
71
+ "get",
72
+ "add",
73
+ "update",
74
+ "delete"
75
+ ]
76
+ },
77
+ "Configsource": {
78
+ "url": "/setting/configsources",
79
+ "method_names": {
80
+ "singular": "configsource",
81
+ "plural": "configsources"
82
+ },
83
+ "actions": [
84
+ "get",
85
+ "add",
86
+ "update",
87
+ "delete"
88
+ ]
89
+ },
90
+ "Function": {
91
+ "url": "/setting/functions",
92
+ "method_names": {
93
+ "singular": "function",
94
+ "plural": "functions"
95
+ },
96
+ "actions": [
97
+ "get",
98
+ "add",
99
+ "update",
100
+ "delete"
101
+ ]
102
+ },
103
+ "OID": {
104
+ "url": "/setting/oids",
105
+ "method_names": {
106
+ "singular": "oid",
107
+ "plural": "oids"
108
+ },
109
+ "actions": [
110
+ "get",
111
+ "add",
112
+ "update",
113
+ "delete"
114
+ ]
115
+ },
116
+ "RecipientGroups": {
117
+ "url": "/setting/recipientgroups",
118
+ "method_names": {
119
+ "singular": "recipient_group",
120
+ "plural": "recipient_groups"
121
+ },
122
+ "actions": [
123
+ "get",
124
+ "add",
125
+ "update",
126
+ "delete"
127
+ ]
128
+ },
129
+ "Service": {
130
+ "url": "/service/services",
131
+ "method_names": {
132
+ "singular": "service",
133
+ "plural": "services"
134
+ },
135
+ "actions": [
136
+ "get",
137
+ "add",
138
+ "update",
139
+ "delete"
140
+ ],
141
+ "children": [
142
+ "SDT"
143
+ ]
144
+ },
145
+ "SiteMonitorCheckpoint": {
146
+ "url": "/service/smcheckpoints",
147
+ "method_names": {
148
+ "singular": "smcheckpoint",
149
+ "plural": "smcheckpoints"
150
+ },
151
+ "actions": [
152
+ "get"
153
+ ]
154
+ },
155
+ "ServiceGroup": {
156
+ "url": "/service/groups",
157
+ "method_names": {
158
+ "singular": "service_group",
159
+ "plural": "service_groups"
160
+ },
161
+ "actions": [
162
+ "get",
163
+ "add",
164
+ "update",
165
+ "delete"
166
+ ],
167
+ "children": [
168
+ "SDT"
169
+ ]
170
+ },
171
+ "User": {
172
+ "url": "/setting/admins",
173
+ "method_names": {
174
+ "singular": "user",
175
+ "plural": "users"
176
+ },
177
+ "actions": [
178
+ "get",
179
+ "add",
180
+ "update",
181
+ "delete"
182
+ ]
183
+ },
184
+ "Role": {
185
+ "url": "/setting/roles",
186
+ "method_names": {
187
+ "singular": "role",
188
+ "plural": "roles"
189
+ },
190
+ "actions": [
191
+ "get",
192
+ "add",
193
+ "update",
194
+ "delete"
195
+ ]
196
+ },
197
+ "APIToken": {
198
+ "url": "/setting/apiTokens",
199
+ "method_names": {
200
+ "singular": "api_token",
201
+ "plural": "api_tokens"
202
+ },
203
+ "actions": [
204
+ "get",
205
+ "add",
206
+ "update",
207
+ "delete"
208
+ ]
209
+ },
210
+ "Device": {
211
+ "url": "/device/devices",
212
+ "method_names": {
213
+ "singular": "device",
214
+ "plural": "devices"
215
+ },
216
+ "actions": [
217
+ "get",
218
+ "add",
219
+ "update",
220
+ "delete"
221
+ ],
222
+ "children": []
223
+ },
224
+ "DeviceGroup": {
225
+ "url": "/device/groups",
226
+ "method_names": {
227
+ "singular": "device_group",
228
+ "plural": "device_groups"
229
+ },
230
+ "actions": [
231
+ "get",
232
+ "add",
233
+ "update",
234
+ "delete"
235
+ ],
236
+ "children": [
237
+ "SDT"
238
+ ]
239
+ },
240
+ "SDT": {
241
+ "url": "/sdt/sdts",
242
+ "method_names": {
243
+ "singular": "sdt",
244
+ "plural": "sdts"
245
+ },
246
+ "actions": [
247
+ "get",
248
+ "add",
249
+ "update",
250
+ "delete"
251
+ ],
252
+ "children": []
253
+ },
254
+ "Dashboard": {
255
+ "url": "/dashboard/dashboards",
256
+ "method_names": {
257
+ "singular": "dashboard",
258
+ "plural": "dashboards"
259
+ },
260
+ "actions": [
261
+ "get",
262
+ "add",
263
+ "update",
264
+ "delete"
265
+ ],
266
+ "children": []
267
+ },
268
+ "Widget": {
269
+ "url": "/dashboard/widgets",
270
+ "method_names": {
271
+ "singular": "widget",
272
+ "plural": "widgets"
273
+ },
274
+ "actions": [
275
+ "get",
276
+ "add",
277
+ "update",
278
+ "delete"
279
+ ],
280
+ "children": []
281
+ },
282
+ "Report": {
283
+ "url": "/report/reports",
284
+ "method_names": {
285
+ "singular": "report",
286
+ "plural": "reports"
287
+ },
288
+ "actions": [
289
+ "get",
290
+ "add",
291
+ "update",
292
+ "delete"
293
+ ],
294
+ "children": []
295
+ },
296
+ "Alert": {
297
+ "url": "/alert/alerts",
298
+ "method_names": {
299
+ "singular": "alert",
300
+ "plural": "alerts"
301
+ },
302
+ "actions": [
303
+ "get"
304
+ ],
305
+ "children": []
306
+ },
307
+ "AlertChain": {
308
+ "url": "/setting/alert/chains",
309
+ "method_names": {
310
+ "singular": "alert_chain",
311
+ "plural": "alert_chains"
312
+ },
313
+ "actions": [
314
+ "get",
315
+ "add",
316
+ "update",
317
+ "delete"
318
+ ],
319
+ "children": []
320
+ },
321
+ "AlertRule": {
322
+ "url": "/setting/alert/rules",
323
+ "method_names": {
324
+ "singular": "alert_rule",
325
+ "plural": "alert_rules"
326
+ },
327
+ "actions": [
328
+ "get",
329
+ "add",
330
+ "update",
331
+ "delete"
332
+ ],
333
+ "children": []
334
+ },
335
+ "ExternalAlerts": {
336
+ "url": "/setting/alert/internalalerts",
337
+ "method_names": {
338
+ "singular": "external_alert",
339
+ "plural": "external_alerts"
340
+ },
341
+ "actions": [
342
+ "get",
343
+ "add",
344
+ "update",
345
+ "delete"
346
+ ],
347
+ "children": []
348
+ },
349
+ "AlertStatus": {
350
+ "url": "/alert/stat",
351
+ "method_names": {
352
+ "singular": "alert_status"
353
+ },
354
+ "actions": [
355
+ "get"
356
+ ]
357
+ },
358
+ "Messages": {
359
+ "url": "/setting/messages",
360
+ "method_names": {
361
+ "singular": "message",
362
+ "plural": "messages"
363
+ },
364
+ "actions": [
365
+ "get"
366
+ ]
367
+ },
368
+ "Timezone": {
369
+ "url": "/setting/timezone",
370
+ "method_names": {
371
+ "singular": "timezone"
372
+ },
373
+ "actions": [
374
+ "get"
375
+ ]
376
+ },
377
+ "Version": {
378
+ "url": "/version",
379
+ "method_names": {
380
+ "singular": "version"
381
+ },
382
+ "actions": [
383
+ "get"
384
+ ]
385
+ }
386
+ }