splunk-sdk-ruby 0.1.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,7 @@ require_relative 'atomfeed'
18
18
  require_relative 'collection'
19
19
  require_relative 'collection/apps'
20
20
  require_relative 'collection/configurations'
21
+ require_relative 'collection/input_kinds'
21
22
  require_relative 'collection/jobs'
22
23
  require_relative 'collection/messages'
23
24
  require_relative 'collection/case_insensitive_collection'
@@ -26,6 +27,7 @@ require_relative 'entity'
26
27
  require_relative 'entity/index'
27
28
  require_relative 'entity/job'
28
29
  require_relative 'entity/message'
30
+ require_relative 'entity/modular_input_kind'
29
31
  require_relative 'entity/saved_search'
30
32
  require_relative 'entity/stanza'
31
33
 
@@ -39,10 +41,12 @@ module Splunk
39
41
  PATH_APPS_LOCAL = ["apps", "local"]
40
42
  PATH_CAPABILITIES = ["authorization", "capabilities"]
41
43
  PATH_LOGGER = ["server","logger"]
42
- PATH_ROLES = ["authentication", "roles"]
43
- PATH_USERS = ['authentication','users']
44
- PATH_MESSAGES = ['messages']
44
+ PATH_ROLES = ["authorization", "roles"]
45
+ PATH_USERS = ["authentication","users"]
46
+ PATH_MESSAGES = ["messages"]
47
+ PATH_MODULAR_INPUT_KINDS = ["data", "modular-inputs"]
45
48
  PATH_INFO = ["server", "info"]
49
+ PATH_INPUTS = ["data", "inputs"]
46
50
  PATH_SETTINGS = ["server", "settings"]
47
51
  PATH_INDEXES = ["data","indexes"]
48
52
  PATH_CONFS = ["properties"]
@@ -219,6 +223,13 @@ module Splunk
219
223
  feed.entries[0]["content"]
220
224
  end
221
225
 
226
+ ##
227
+ # Return a collection of the input kinds.
228
+ #
229
+ def inputs
230
+ InputKinds.new(self, PATH_INPUTS)
231
+ end
232
+
222
233
  ##
223
234
  # Returns a collection of all the search jobs running on Splunk.
224
235
  #
@@ -272,6 +283,27 @@ module Splunk
272
283
  Messages.new(self, PATH_MESSAGES, entity_class=Message)
273
284
  end
274
285
 
286
+ ##
287
+ # Returns a read only collection of modular input kinds.
288
+ #
289
+ # The modular input kinds are custom input kinds on this Splunk instance.
290
+ # To access the actual inputs of these kinds, use the +Service+#+inputs+
291
+ # method. This method gives access to the metadata describing the input
292
+ # kinds.
293
+ #
294
+ # Returns: A +ReadOnlyCollection+ of +ModularInputKind+ objects representing
295
+ # all the custom input types added to this Splunk instance.
296
+ #
297
+ def modular_input_kinds
298
+ if self.splunk_version[0] < 5
299
+ raise IllegalOperation.new("Modular input kinds are " +
300
+ "not supported before Splunk 5.0")
301
+ else
302
+ ReadOnlyCollection.new(self, PATH_MODULAR_INPUT_KINDS,
303
+ entity_class=ModularInputKind)
304
+ end
305
+ end
306
+
275
307
  ##
276
308
  # Returns a collection of the roles on the system.
277
309
  #
@@ -320,8 +352,8 @@ module Splunk
320
352
  #
321
353
  # The version is represented as an +Array+ of length 3, with each
322
354
  # of its components an integer. For example, on Splunk 4.3.5,
323
- # +splunk_version+ would return [+4, 3, 5+], while on Splunk 5.0.2,
324
- # +splunk_version+ would return [+5, 0, 2+].
355
+ # +splunk_version+ would return [+4+, +3+, +5+], while on Splunk 5.0.2,
356
+ # +splunk_version+ would return [+5+, +0+, +2+].
325
357
  #
326
358
  # Returns: An +Array+ of +Integers+ of length 3.
327
359
  #
@@ -23,5 +23,5 @@
23
23
  # release new versions.
24
24
  #
25
25
  module Splunk
26
- VERSION = '0.1.0'
26
+ VERSION = '0.8.1'
27
27
  end
@@ -113,5 +113,16 @@ module Splunk
113
113
  end
114
114
  end
115
115
  end
116
+
117
+ ##
118
+ # Escape reserved XML entities in a string.
119
+ #
120
+ # To match the behavior of splunkd, we only escape &, <, and >, not single
121
+ # and double quotes. This means we have to write the behavior ourselves,
122
+ # since both REXML and Nokogiri also escape both kinds of quotes.
123
+ #
124
+ def self.escape_string(str)
125
+ str.gsub(/&/, "&amp;").gsub(/</, "&lt;").gsub(/>/, "&gt;")
126
+ end
116
127
  end
117
128
 
@@ -2,18 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'splunk-sdk-ruby'
5
- gem.version = '0.1.0'
5
+ gem.version = '0.8.1'
6
6
 
7
7
  gem.authors = ['Splunk']
8
8
  gem.email = ['devinfo@splunk.com']
9
9
  gem.description = %q{Splunk SDK for Ruby}
10
10
  gem.summary = %q{Ruby bindings to Splunk REST layer}
11
11
  gem.homepage = 'http://dev.splunk.com'
12
+ gem.license = 'APL2'
12
13
 
13
14
  gem.required_ruby_version = '>=1.9.2'
14
15
  gem.add_dependency 'jruby-openssl', '~>0.7.7' if RUBY_PLATFORM == "java"
15
16
  gem.add_dependency 'rake', '~>10'
16
- gem.add_dependency 'test-unit'
17
+ gem.add_development_dependency 'test-unit'
17
18
 
18
19
  gem.files = Dir['{lib,examples,test}/**/*',
19
20
  'CHANGELOG.md',
@@ -0,0 +1,457 @@
1
+ {
2
+ "atom_with_feed": {
3
+ "metadata": {
4
+ "title": "localapps",
5
+ "id": "https://localhost:8089/servicesNS/nobody/system/apps/local",
6
+ "updated": "2012-12-19T11:07:48-08:00",
7
+ "generator": {"build": "144175", "version": "5.0.2"},
8
+ "author": "Splunk",
9
+ "links": {
10
+ "create": "/servicesNS/nobody/system/apps/local/_new",
11
+ "_reload": "/servicesNS/nobody/system/apps/local/_reload"
12
+ },
13
+ "totalResults": "1",
14
+ "itemsPerPage": "30",
15
+ "startIndex": "0",
16
+ "messages": []
17
+ },
18
+ "entries": [
19
+ {
20
+ "title": "gettingstarted",
21
+ "id": "https://localhost:8089/servicesNS/nobody/system/apps/local/gettingstarted",
22
+ "updated": "2012-12-19T11:07:48-08:00",
23
+ "author": "nobody",
24
+ "links": {
25
+ "alternate": "/servicesNS/nobody/system/apps/local/gettingstarted",
26
+ "list": "/servicesNS/nobody/system/apps/local/gettingstarted",
27
+ "_reload": "/servicesNS/nobody/system/apps/local/gettingstarted/_reload",
28
+ "edit": "/servicesNS/nobody/system/apps/local/gettingstarted",
29
+ "remove": "/servicesNS/nobody/system/apps/local/gettingstarted",
30
+ "disable": "/servicesNS/nobody/system/apps/local/gettingstarted/disable",
31
+ "package": "/servicesNS/nobody/system/apps/local/gettingstarted/package"
32
+ },
33
+ "content": {
34
+ "author": "Splunk",
35
+ "check_for_updates": "1",
36
+ "configured": "1",
37
+ "description": "Get started with Splunk. This app introduces you to many of Splunk's features. You'll learn how to use Splunk to index data, search and investigate, add knowledge, monitor and alert, report and analyze.",
38
+ "disabled": "0",
39
+ "eai:acl": {
40
+ "app": "system",
41
+ "can_change_perms": "1",
42
+ "can_list": "1",
43
+ "can_share_app": "1",
44
+ "can_share_global": "1",
45
+ "can_share_user": "0",
46
+ "can_write": "1",
47
+ "modifiable": "1",
48
+ "owner": "nobody",
49
+ "perms": {
50
+ "read": ["*"],
51
+ "write": ["power"]
52
+ },
53
+ "removable": "0",
54
+ "sharing": "app"
55
+ },
56
+ "eai:attributes": {
57
+ "optionalFields": ["author", "check_for_updates",
58
+ "configured", "description",
59
+ "label", "manageable", "version",
60
+ "visible"],
61
+ "requiredFields": [],
62
+ "wildcardFields": []
63
+ },
64
+ "label": "Getting started",
65
+ "manageable": "1",
66
+ "state_change_requires_restart": "0",
67
+ "version": "1.0",
68
+ "visible": "1"
69
+ }
70
+ }
71
+ ]
72
+ },
73
+ "atom_without_feed": {
74
+ "metadata": {},
75
+ "entries": [
76
+ {
77
+ "title": "| metadata type=sources | search totalCount>0 | rename totalCount as Count recentTime as \"Last Update\" | table source Count \"Last Update\" | fieldformat Count=tostring(Count, \"commas\") | fieldformat \"Last Update\"=strftime('Last Update', \"%c\")",
78
+ "id": "https://localhost:8089/services/search/jobs/rt_1355944187.129",
79
+ "updated": "2012-12-19T11:09:52.000-08:00",
80
+ "published": "2012-12-19T11:09:47.000-08:00",
81
+ "links": {
82
+ "alternate": "/services/search/jobs/rt_1355944187.129",
83
+ "search.log": "/services/search/jobs/rt_1355944187.129/search.log",
84
+ "events": "/services/search/jobs/rt_1355944187.129/events",
85
+ "results": "/services/search/jobs/rt_1355944187.129/results",
86
+ "results_preview": "/services/search/jobs/rt_1355944187.129/results_preview",
87
+ "timeline": "/services/search/jobs/rt_1355944187.129/timeline",
88
+ "summary": "/services/search/jobs/rt_1355944187.129/summary",
89
+ "control": "/services/search/jobs/rt_1355944187.129/control"
90
+ },
91
+ "author": "admin",
92
+ "content": {
93
+ "cursorTime": "1969-12-31T16:00:00.000-08:00",
94
+ "delegate": "",
95
+ "diskUsage": "49152",
96
+ "dispatchState": "RUNNING",
97
+ "doneProgress": "1.00000",
98
+ "dropCount": "0",
99
+ "earliestTime": "1969-12-31T16:00:00.000-08:00",
100
+ "eventAvailableCount": "0",
101
+ "eventCount": "0",
102
+ "eventFieldCount": "0",
103
+ "eventIsStreaming": "1",
104
+ "eventIsTruncated": "1",
105
+ "eventSearch": "",
106
+ "eventSorting": "none",
107
+ "isDone": "0",
108
+ "isFailed": "0",
109
+ "isFinalized": "0",
110
+ "isPaused": "0",
111
+ "isPreviewEnabled": "1",
112
+ "isRealTimeSearch": "1",
113
+ "isRemoteTimeline": "0",
114
+ "isSaved": "0",
115
+ "isSavedSearch": "0",
116
+ "isZombie": "0",
117
+ "keywords": "",
118
+ "label": "",
119
+ "latestTime": "1969-12-31T16:00:00.000-08:00",
120
+ "meanPreviewPeriod": "1.708000",
121
+ "numPreviews": "3",
122
+ "pid": "11902",
123
+ "priority": "5",
124
+ "remoteSearch": "metadata gather=false type=sources update_period=0",
125
+ "reportSearch": "metadata type=sources | search totalCount>0 | rename totalCount as Count recentTime as \"Last Update\" | table source Count \"Last Update\" ",
126
+ "resultCount": "0",
127
+ "resultIsStreaming": "0",
128
+ "resultPreviewCount": "5",
129
+ "runDuration": "5.124000",
130
+ "scanCount": "0",
131
+ "sid": "rt_1355944187.129",
132
+ "statusBuckets": "0",
133
+ "ttl": "599",
134
+ "performance": {
135
+ "command.metadata": {
136
+ "duration_secs": "4.995000",
137
+ "invocations": "9",
138
+ "input_count": "0",
139
+ "output_count": "6"
140
+ },
141
+ "command.metadata.execute_input": {
142
+ "duration_secs": "0.009000",
143
+ "invocations": "9"
144
+ },
145
+ "dispatch.check_disk_usage": {
146
+ "duration_secs": "0.001000",
147
+ "invocations": "1"
148
+ },
149
+ "dispatch.createProviderQueue": {
150
+ "duration_secs": "0.005000",
151
+ "invocations": "1"
152
+ },
153
+ "dispatch.evaluate": {
154
+ "duration_secs": "0.028000",
155
+ "invocations": "1"
156
+ },
157
+ "dispatch.evaluate.fieldformat": {
158
+ "duration_secs": "0.002000",
159
+ "invocations": "2"
160
+ },
161
+ "dispatch.evaluate.metadata": {
162
+ "duration_secs": "0.003000",
163
+ "invocations": "1"
164
+ },
165
+ "dispatch.evaluate.rename": {
166
+ "duration_secs": "0.001000",
167
+ "invocations": "1"
168
+ },
169
+ "dispatch.evaluate.search": {
170
+ "duration_secs": "0.021000",
171
+ "invocations": "1"
172
+ },
173
+ "dispatch.evaluate.table": {
174
+ "duration_secs": "0.001000",
175
+ "invocations": "1"
176
+ },
177
+ "dispatch.fetch": {
178
+ "duration_secs": "4.996000",
179
+ "invocations": "9"
180
+ },
181
+ "dispatch.preview": {
182
+ "duration_secs": "0.088000",
183
+ "invocations": "3"
184
+ },
185
+ "dispatch.preview.command.rename": {
186
+ "duration_secs": "0.004000",
187
+ "invocations": "3",
188
+ "input_count": "15",
189
+ "output_count": "15"
190
+ },
191
+ "dispatch.preview.command.search": {
192
+ "duration_secs": "0.057000",
193
+ "invocations": "3",
194
+ "input_count": "15",
195
+ "output_count": "15"
196
+ },
197
+ "dispatch.preview.command.search.filter": {
198
+ "duration_secs": "0.003000",
199
+ "invocations": "3"
200
+ },
201
+ "dispatch.preview.command.table": {
202
+ "duration_secs": "0.013000",
203
+ "invocations": "3",
204
+ "input_count": "15",
205
+ "output_count": "30"
206
+ },
207
+ "dispatch.preview.metadata.execute_output": {
208
+ "duration_secs": "0.003000",
209
+ "invocations": "3"
210
+ },
211
+ "dispatch.preview.write_results_to_disk": {
212
+ "duration_secs": "0.015000",
213
+ "invocations": "3"
214
+ },
215
+ "dispatch.stream.local": {
216
+ "duration_secs": "4.996000",
217
+ "invocations": "9"
218
+ },
219
+ "dispatch.writeStatus": {
220
+ "duration_secs": "0.013000",
221
+ "invocations": "6"
222
+ },
223
+ "startup.handoff": {
224
+ "duration_secs": "0.138000",
225
+ "invocations": "1"
226
+ }
227
+ },
228
+ "messages": {},
229
+ "request": {
230
+ "auto_cancel": "90",
231
+ "earliest_time": "rt",
232
+ "latest_time": "rt",
233
+ "max_count": "100000",
234
+ "search": "| metadata type=sources | search totalCount>0 | rename totalCount as Count recentTime as \"Last Update\" | table source Count \"Last Update\" | fieldformat Count=tostring(Count, \"commas\") | fieldformat \"Last Update\"=strftime('Last Update', \"%c\")",
235
+ "status_buckets": "0",
236
+ "time_format": "%s.%Q",
237
+ "ui_dispatch_app": "search",
238
+ "ui_dispatch_view": "dashboard_live"
239
+ },
240
+ "eai:acl": {
241
+ "perms": {
242
+ "read": ["admin"],
243
+ "write": ["admin"]
244
+ },
245
+ "owner": "admin",
246
+ "modifiable": "1",
247
+ "sharing": "global",
248
+ "app": "search",
249
+ "can_write": "1"
250
+ },
251
+ "searchProviders": ["fross-mbp15.local"]
252
+ }
253
+ }
254
+ ]
255
+ },
256
+ "atom_with_several_entries": {
257
+ "metadata": {
258
+ "title": "localapps",
259
+ "id": "https://localhost:8089/services/apps/local",
260
+ "updated": "2012-12-19T15:27:58-08:00",
261
+ "generator": {"version": "140437"},
262
+ "author": "Splunk",
263
+ "links": {
264
+ "create": "/services/apps/local/_new",
265
+ "_reload": "/services/apps/local/_reload"
266
+ },
267
+ "totalResults": "12",
268
+ "itemsPerPage": "30",
269
+ "startIndex": "0",
270
+ "messages": []
271
+ },
272
+ "entries": [
273
+ {
274
+ "title": "gettingstarted",
275
+ "id": "https://localhost:8089/services/apps/local/gettingstarted",
276
+ "updated": "2012-12-19T15:27:58-08:00",
277
+ "author": "system",
278
+ "links": {
279
+ "alternate": "/services/apps/local/gettingstarted",
280
+ "list": "/services/apps/local/gettingstarted",
281
+ "_reload": "/services/apps/local/gettingstarted/_reload",
282
+ "edit": "/services/apps/local/gettingstarted",
283
+ "remove": "/services/apps/local/gettingstarted",
284
+ "disable": "/services/apps/local/gettingstarted/disable",
285
+ "package": "/services/apps/local/gettingstarted/package"
286
+ },
287
+ "content": {
288
+ "author": "Splunk",
289
+ "check_for_updates": "1",
290
+ "configured": "1",
291
+ "description": "Get started with Splunk. This app introduces you to many of Splunk's features. You'll learn how to use Splunk to index data, search and investigate, add knowledge, monitor and alert, report and analyze.",
292
+ "disabled": "0",
293
+ "eai:acl": {
294
+ "app": "",
295
+ "can_change_perms": "1",
296
+ "can_list": "1",
297
+ "can_share_app": "1",
298
+ "can_share_global": "1",
299
+ "can_share_user": "0",
300
+ "can_write": "1",
301
+ "modifiable": "1",
302
+ "owner": "system",
303
+ "perms": {
304
+ "read": ["*"],
305
+ "write": ["power"]
306
+ },
307
+ "removable": "0",
308
+ "sharing": "app"
309
+ },
310
+ "label": "Getting started",
311
+ "manageable": "0",
312
+ "state_change_requires_restart": "0",
313
+ "version": "1.0",
314
+ "visible": "1"
315
+ }
316
+ },
317
+ {
318
+ "title": "launcher",
319
+ "id": "https://localhost:8089/services/apps/local/launcher",
320
+ "updated": "2012-12-19T15:27:58-08:00",
321
+ "author": "system",
322
+ "links": {
323
+ "alternate": "/services/apps/local/launcher",
324
+ "list": "/services/apps/local/launcher",
325
+ "_reload": "/services/apps/local/launcher/_reload",
326
+ "edit": "/services/apps/local/launcher",
327
+ "remove": "/services/apps/local/launcher",
328
+ "package": "/services/apps/local/launcher/package"
329
+ },
330
+ "content": {
331
+ "check_for_updates": "1",
332
+ "configured": "1",
333
+ "disabled": "0",
334
+ "eai:acl": {
335
+ "app": "",
336
+ "can_change_perms": "1",
337
+ "can_list": "1",
338
+ "can_share_app": "1",
339
+ "can_share_global": "1",
340
+ "can_share_user": "0",
341
+ "can_write": "1",
342
+ "modifiable": "1",
343
+ "owner": "system",
344
+ "perms": {
345
+ "read": ["*"],
346
+ "write": ["power"]
347
+ },
348
+ "removable": "0",
349
+ "sharing": "app"
350
+ },
351
+ "label": "Home",
352
+ "manageable": "0",
353
+ "state_change_requires_restart": "0",
354
+ "visible": "1"
355
+ }
356
+ },
357
+
358
+ {
359
+ "title": "learned",
360
+ "id": "https://localhost:8089/services/apps/local/learned",
361
+ "updated": "2012-12-19T15:27:58-08:00",
362
+ "author": "system",
363
+ "links": {
364
+ "alternate": "/services/apps/local/learned",
365
+ "list": "/services/apps/local/learned",
366
+ "_reload": "/services/apps/local/learned/_reload",
367
+ "edit": "/services/apps/local/learned",
368
+ "remove": "/services/apps/local/learned",
369
+ "disable": "/services/apps/local/learned/disable",
370
+ "package": "/services/apps/local/learned/package"
371
+ },
372
+ "content": {
373
+ "check_for_updates": "1",
374
+ "configured": "0",
375
+ "disabled": "0",
376
+ "eai:acl": {
377
+ "app": "",
378
+ "can_change_perms": "1",
379
+ "can_list": "1",
380
+ "can_share_app": "1",
381
+ "can_share_global": "1",
382
+ "can_share_user": "0",
383
+ "can_write": "1",
384
+ "modifiable": "1",
385
+ "owner": "system",
386
+ "perms": {"read": ["*"], "write": ["*"]},
387
+ "removable": "0",
388
+ "sharing": "app"
389
+ },
390
+ "label": "learned",
391
+ "manageable": "1",
392
+ "state_change_requires_restart": "0",
393
+ "visible": "0"
394
+ }
395
+ }
396
+ ]
397
+ },
398
+ "atom_with_simple_entries": {
399
+ "metadata": {
400
+ "title": "services",
401
+ "id": "https://localhost:8089/services/",
402
+ "updated": "2012-12-20T09:48:01-08:00",
403
+ "generator": {"version": "140437"},
404
+ "author": "Splunk",
405
+ "links": {},
406
+ "messages": []
407
+ },
408
+ "entries": [
409
+ {
410
+ "title": "alerts",
411
+ "id": "https://localhost:8089/services/alerts",
412
+ "updated": "2012-12-20T09:48:01-08:00",
413
+ "links": {
414
+ "alternate": "/services/alerts"
415
+ }
416
+ },
417
+ {
418
+ "title": "apps",
419
+ "id": "https://localhost:8089/services/apps",
420
+ "updated": "2012-12-20T09:48:01-08:00",
421
+ "links": {
422
+ "alternate": "/services/apps"
423
+ }
424
+ },
425
+ {
426
+ "title": "auth",
427
+ "id": "https://localhost:8089/services/auth",
428
+ "updated": "2012-12-20T09:48:01-08:00",
429
+ "links": {
430
+ "alternate": "/services/auth"
431
+ }
432
+ }
433
+ ]
434
+ },
435
+ "atom_feed_with_message": {
436
+ "metadata": {
437
+ "title": "roles",
438
+ "id": "https://localhost:8089/services/authorization/roles",
439
+ "updated": "2013-01-22T08:52:24-08:00",
440
+ "generator": {"build": "146385", "version": "5.0.2"},
441
+ "author": "Splunk",
442
+ "links": {
443
+ "create": "/services/authorization/roles/_new"
444
+ },
445
+ "startIndex": "0",
446
+ "totalResults": "0",
447
+ "itemsPerPage": "30",
448
+ "messages": [
449
+ {
450
+ "type": "WARN",
451
+ "message": "This role will be disabled after the Enterprise Trial License expires"
452
+ }
453
+ ]
454
+ },
455
+ "entries": []
456
+ }
457
+ }