splunk-sdk-ruby 1.0.4 → 1.0.5

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
  SHA1:
3
- metadata.gz: b3c38b77a9adcc58802292d0d327961f78aec70b
4
- data.tar.gz: 6a3dd18f3a37e32f82753f695655e89f26f43367
3
+ metadata.gz: 34a1f802857efc8505ade417d3dd2d75de7a8c30
4
+ data.tar.gz: 2a8068e47040a22d4148f1db614965a64a3ec368
5
5
  SHA512:
6
- metadata.gz: 27cdf2cc8daa4b942cc23a266630fa5bc4c58fac9eb7b789b7858712df257aecdaf1ff42d91e20a66dd61924fdfa81a419b52cad1d925afd104f7eeb8a44b7f1
7
- data.tar.gz: 0d782c21487ac3d410263cd4590509185e71c2c1805cb250d654384e7f8c380582de7853ff0d0eb72fe3627d0067842036ac12d5bbb16689735e40f657c6dca5
6
+ metadata.gz: f41166be1bff0c9479246d6ef477954f3d54b27f295f5bb38051422b9d99fb8021b3df08f9d8bef884f63ecb9ba91a4c1299e43f645fbd8bc71d426eec7db3cd
7
+ data.tar.gz: a05a8a35e1f459a7e39fcdb63869e20cf4cc3c5fe7868a9bf6fae057bbbc727d48288f4157cac9a4c4a330748d943d877d07be8518e2ee5d89b0527192e3d71b
@@ -1,5 +1,10 @@
1
1
  # Splunk SDK for Ruby Changelog
2
2
 
3
+ ## Version 1.0.5
4
+
5
+ * Added support for basic authentication.
6
+ * Added an example for load balanced search heads.
7
+
3
8
  ## Version 1.0.4
4
9
 
5
10
  * Added support for client certificates and path prefix.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The Splunk Software Development Kit for Ruby
2
2
 
3
- #### Version 1.0.4
3
+ #### Version 1.0.5
4
4
 
5
5
  This Splunk Software Development Kit (SDK) for Ruby contains library code and
6
6
  examples designed to enable developers to build applications using Splunk.
data/Rakefile CHANGED
@@ -4,20 +4,6 @@ require 'rubygems/specification'
4
4
  require 'rake/testtask'
5
5
  require 'date'
6
6
 
7
- spec = Gem::Specification.new do |s|
8
- s.name = "splunk-sdk"
9
- s.version = "0.1.0"
10
- s.author = "Splunk"
11
- s.email = "devinfo@splunk.com"
12
- s.homepage = "http://dev.splunk.com"
13
- s.summary = "SDK for easily working with Splunk from Ruby."
14
- s.description = s.summary
15
- s.has_rdoc = true
16
- s.extra_rdoc_files = ["README", "LICENSE", "TODO"]
17
- s.require_path = "lib"
18
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob('{lib,test}/**/*')
19
- end
20
-
21
7
  task :default => :help
22
8
 
23
9
  desc "Print help on using the Rakefile for the Ruby SDK for Splunk."
@@ -36,5 +22,5 @@ end
36
22
  Rake::TestTask.new do |t|
37
23
  t.libs << "test"
38
24
  t.pattern = "test/test_*.rb"
39
- t.verbose = true
25
+ t.options = "-v"
40
26
  end
@@ -0,0 +1,44 @@
1
+ #--
2
+ # Copyright 2011-2015 Splunk, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"): you may
5
+ # not use this file except in compliance with the License. You may obtain
6
+ # a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+ #++
16
+
17
+ require 'splunk-sdk-ruby'
18
+
19
+ # How to get to the Splunk server. Edit this to match your
20
+ # own Splunk install.
21
+ config = {
22
+ :scheme => :https,
23
+ :host => "localhost",
24
+ :port => 8089,
25
+ :username => "admin",
26
+ :password => "changeme",
27
+ # Set basic = true to use basic auth instead of token auth
28
+ :basic => true
29
+ }
30
+
31
+ # Create a Service logged into Splunk.
32
+ service = Splunk::connect(config)
33
+
34
+ # Access some resource
35
+ num_apps = service.apps().length
36
+ puts "Found #{num_apps} apps on #{config[:host]}"
37
+
38
+ # Mock the behavior of a load balancer
39
+ config[:host] = "127.0.0.1"
40
+ service = Splunk::connect(config)
41
+
42
+ # Access some resource again
43
+ num_apps = service.apps().length
44
+ puts "Found #{num_apps} apps on #{config[:host]}"
@@ -63,6 +63,7 @@ module Splunk
63
63
  # * +:ssl_client_cert+ A +OpenSSL::X509::Certificate+ object to use as a client certificate.
64
64
  # * +:ssl_client_key+ A +OpenSSL::PKey::RSA+ or +OpenSSL::PKey::DSA+ object to use as a client key.
65
65
  # * +:token+ - a preauthenticated Splunk token (default: +nil+)
66
+ # * +:basic+ - indicates if HTTP Basic Auth is going to be used (default: +false+)
66
67
  #
67
68
  # If you specify a token, you need not specify a username or password, nor
68
69
  # do you need to call the +login+ method.
@@ -87,6 +88,7 @@ module Splunk
87
88
  @namespace = args.fetch(:namespace,
88
89
  Splunk::namespace(:sharing => "default"))
89
90
  @proxy = args.fetch(:proxy, nil)
91
+ @basic = args.fetch(:basic, false)
90
92
  @path_prefix = args.fetch(:path_prefix, DEFAULT_PATH_PREFIX)
91
93
  @ssl_client_cert = args.fetch(:ssl_client_cert, nil)
92
94
  @ssl_client_key = args.fetch(:ssl_client_key, nil)
@@ -223,9 +225,11 @@ module Splunk
223
225
  #
224
226
  def login()
225
227
  if @token # If we're already logged in, this method is a nop.
226
- return
228
+ return self
229
+ end
230
+ if @basic # We're using basic authentication, thus making this a nop
231
+ return self
227
232
  end
228
-
229
233
  response = request(:namespace => Splunk::namespace(:sharing => "default"),
230
234
  :method => :POST,
231
235
  :resource => ["auth", "login"],
@@ -418,6 +422,11 @@ module Splunk
418
422
  # Headers
419
423
  request["User-Agent"] = "splunk-sdk-ruby/#{VERSION}"
420
424
  request["Authorization"] = "Splunk #{@token}" if @token
425
+
426
+ # basic authentication supercedes Splunk authentication
427
+ if @basic then
428
+ request.basic_auth(@username, @password)
429
+ end
421
430
  headers.each_entry do |key, value|
422
431
  request[key] = value
423
432
  end
@@ -23,5 +23,5 @@
23
23
  # release new versions.
24
24
  #
25
25
  module Splunk
26
- VERSION = '1.0.4'
26
+ VERSION = '1.0.5'
27
27
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'splunk-sdk-ruby'
5
- gem.version = '1.0.4'
5
+ gem.version = '1.0.5'
6
6
 
7
7
  gem.authors = ['Splunk']
8
8
  gem.email = ['devinfo@splunk.com']
@@ -57,6 +57,15 @@ class TestContext < TestCaseWithSplunkConnection
57
57
  assert_logged_in(new_service)
58
58
  end
59
59
 
60
+ def test_authenticate_with_basic
61
+ new_arguments = @splunkrc.clone
62
+ new_arguments[:basic] = true
63
+
64
+ new_service = Context.new(new_arguments)
65
+ assert_logged_in(new_service)
66
+ assert_equal(new_service.request(:resource => ["apps", "local"]).code, "200")
67
+ end
68
+
60
69
  def test_failed_login()
61
70
  args = @splunkrc.clone()
62
71
  args[:username] = args[:username] + "-boris"
@@ -99,7 +99,7 @@ class JobsTestCase < TestCaseWithSplunkConnection
99
99
  def test_export_on_reporting_search
100
100
  stream = @service.create_export("search index=_internal earliest=-2d | stats count(_raw) by method")
101
101
  results = ResultsReader.new(stream).to_a()
102
- assert_true(3 >= results.length())
102
+ assert_true(3 <= results.length())
103
103
  end
104
104
 
105
105
  ##
@@ -340,27 +340,27 @@ class LongJobTestCase < JobsTestCase
340
340
  ttl <= new_ttl && ttl > old_ttl
341
341
  end
342
342
  end
343
-
344
- def test_touch
345
- # Any request resets the TTL in Splunk 6.0. This was an error that
346
- # has been filed and will be reverted (TODO: Insert Jira number once dnoble logs it).
347
- if @service.splunk_version[0,2] == [6,0]
348
- return
349
- end
350
- i = 2
351
- while i < 20
352
- sleep(i)
353
- old_ttl = Integer(@job.refresh()["ttl"])
354
- @job.touch()
355
- new_ttl = Integer(@job.refresh()["ttl"])
356
- if new_ttl > old_ttl
357
- break
358
- else
359
- i += 1
360
- end
361
- end
362
- assert_true(new_ttl > old_ttl)
363
- end
343
+ # NOTE: this test is no longer relevant due to some changes in Splunk 6.0+
344
+ # def test_touch
345
+ # # Any request resets the TTL in Splunk 6.0. This was an error that
346
+ # # has been filed and will be reverted (TODO: Insert Jira number once dnoble logs it).
347
+ # if @service.splunk_version[0,2] == [6,0]
348
+ # return
349
+ # end
350
+ # i = 2
351
+ # while i < 20
352
+ # sleep(i)
353
+ # old_ttl = Integer(@job.refresh()["ttl"])
354
+ # @job.touch()
355
+ # new_ttl = Integer(@job.refresh()["ttl"])
356
+ # if new_ttl > old_ttl
357
+ # break
358
+ # else
359
+ # i += 1
360
+ # end
361
+ # end
362
+ # assert_true(new_ttl > old_ttl)
363
+ # end
364
364
  end
365
365
 
366
366
  class RealTimeJobTestCase < JobsTestCase
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splunk-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Splunk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test-unit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Splunk SDK for Ruby
@@ -45,24 +45,8 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - CHANGELOG.md
49
- - Gemfile
50
- - LICENSE
51
- - README.md
52
- - Rakefile
53
- - examples/1_connect.rb
54
- - examples/2_manage.rb
55
- - examples/3_blocking_searches.rb
56
- - examples/4_asynchronous_searches.rb
57
- - examples/5_stream_data_to_splunk.rb
58
- - examples/6_work_with_modular_inputs.rb
59
- - examples/connect_via_reverse_proxy.rb
60
- - examples/example_modular_inputs.spl
61
- - examples/run_examples.rb
62
- - lib/splunk-sdk-ruby.rb
63
48
  - lib/splunk-sdk-ruby/ambiguous_entity_reference.rb
64
49
  - lib/splunk-sdk-ruby/atomfeed.rb
65
- - lib/splunk-sdk-ruby/collection.rb
66
50
  - lib/splunk-sdk-ruby/collection/apps.rb
67
51
  - lib/splunk-sdk-ruby/collection/case_insensitive_collection.rb
68
52
  - lib/splunk-sdk-ruby/collection/configuration_file.rb
@@ -70,14 +54,15 @@ files:
70
54
  - lib/splunk-sdk-ruby/collection/input_kinds.rb
71
55
  - lib/splunk-sdk-ruby/collection/jobs.rb
72
56
  - lib/splunk-sdk-ruby/collection/messages.rb
57
+ - lib/splunk-sdk-ruby/collection.rb
73
58
  - lib/splunk-sdk-ruby/context.rb
74
- - lib/splunk-sdk-ruby/entity.rb
75
59
  - lib/splunk-sdk-ruby/entity/index.rb
76
60
  - lib/splunk-sdk-ruby/entity/job.rb
77
61
  - lib/splunk-sdk-ruby/entity/message.rb
78
62
  - lib/splunk-sdk-ruby/entity/modular_input_kind.rb
79
63
  - lib/splunk-sdk-ruby/entity/saved_search.rb
80
64
  - lib/splunk-sdk-ruby/entity/stanza.rb
65
+ - lib/splunk-sdk-ruby/entity.rb
81
66
  - lib/splunk-sdk-ruby/entity_not_ready.rb
82
67
  - lib/splunk-sdk-ruby/illegal_operation.rb
83
68
  - lib/splunk-sdk-ruby/namespace.rb
@@ -87,7 +72,17 @@ files:
87
72
  - lib/splunk-sdk-ruby/synonyms.rb
88
73
  - lib/splunk-sdk-ruby/version.rb
89
74
  - lib/splunk-sdk-ruby/xml_shim.rb
90
- - splunk-sdk-ruby.gemspec
75
+ - lib/splunk-sdk-ruby.rb
76
+ - examples/1_connect.rb
77
+ - examples/2_manage.rb
78
+ - examples/3_blocking_searches.rb
79
+ - examples/4_asynchronous_searches.rb
80
+ - examples/5_stream_data_to_splunk.rb
81
+ - examples/6_work_with_modular_inputs.rb
82
+ - examples/connect_load_balanced_search_heads.rb
83
+ - examples/connect_via_reverse_proxy.rb
84
+ - examples/example_modular_inputs.spl
85
+ - examples/run_examples.rb
91
86
  - test/data/atom/atom_feed_with_message.xml
92
87
  - test/data/atom/atom_with_feed.xml
93
88
  - test/data/atom/atom_with_several_entries.xml
@@ -133,6 +128,12 @@ files:
133
128
  - test/test_users.rb
134
129
  - test/test_xml_shim.rb
135
130
  - test/testfile.txt
131
+ - CHANGELOG.md
132
+ - LICENSE
133
+ - README.md
134
+ - Gemfile
135
+ - Rakefile
136
+ - splunk-sdk-ruby.gemspec
136
137
  homepage: http://dev.splunk.com
137
138
  licenses:
138
139
  - APL2
@@ -143,17 +144,17 @@ require_paths:
143
144
  - lib
144
145
  required_ruby_version: !ruby/object:Gem::Requirement
145
146
  requirements:
146
- - - ">="
147
+ - - '>='
147
148
  - !ruby/object:Gem::Version
148
149
  version: 1.9.2
149
150
  required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
- - - ">="
152
+ - - '>='
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
156
  rubyforge_project:
156
- rubygems_version: 2.4.1
157
+ rubygems_version: 2.0.14
157
158
  signing_key:
158
159
  specification_version: 4
159
160
  summary: Ruby bindings to Splunk REST layer