splunk-sdk-ruby 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/examples/connect_via_reverse_proxy.rb +66 -0
- data/lib/splunk-sdk-ruby/context.rb +38 -2
- data/lib/splunk-sdk-ruby/version.rb +1 -1
- data/splunk-sdk-ruby.gemspec +3 -3
- metadata +46 -45
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
N2Y0OWM1OTg3ZWVjYmJiYmY1NjZlNzM5YzY4MDA5ZTU0OTYzZDYyNA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3c38b77a9adcc58802292d0d327961f78aec70b
|
4
|
+
data.tar.gz: 6a3dd18f3a37e32f82753f695655e89f26f43367
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YjdmNjYzMTYzZWQxZWRhYmQ5MDJlNGRkN2Q0NmE5YTQxMWExZGZiZjA2ZTcz
|
11
|
-
ZDA0MzJjMDgzY2MzZDFmZDYyNmQ0OTdjZjVkMzg3NDg2MjdjODM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NjA5N2I4ZDE4ZGQxNDU2MDgxNWM0MGQ1NzlhOTc4OTRlNDE5ZmUzMGJlOTAx
|
14
|
-
ZWIyZmE0MTM0YWVhODM5NWVjMmYzYWUyMmZlZjEzOGQzYjI4MGFhNDA1ZjFj
|
15
|
-
Mjc3OTdmY2NiYjg4ODJkZDUzZmFlNmQ2ZjhjOTg3OGVmODA3Y2I=
|
6
|
+
metadata.gz: 27cdf2cc8daa4b942cc23a266630fa5bc4c58fac9eb7b789b7858712df257aecdaf1ff42d91e20a66dd61924fdfa81a419b52cad1d925afd104f7eeb8a44b7f1
|
7
|
+
data.tar.gz: 0d782c21487ac3d410263cd4590509185e71c2c1805cb250d654384e7f8c380582de7853ff0d0eb72fe3627d0067842036ac12d5bbb16689735e40f657c6dca5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Splunk SDK for Ruby Changelog
|
2
2
|
|
3
|
+
## Version 1.0.4
|
4
|
+
|
5
|
+
* Added support for client certificates and path prefix.
|
6
|
+
* Added an option to specify a proxy server to use. Includes connect_via_proxy.rb example.
|
7
|
+
* Minor Fixes
|
8
|
+
|
3
9
|
## Version 1.0.3
|
4
10
|
|
5
11
|
* Splunk SDK for Ruby now works with Splunk 6.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2011-2012 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
|
+
# Your client certififcate that grants access to the reverse proxy.
|
20
|
+
CERT_PATH = "#{ENV['HOME']}/.ssl/client.p12"
|
21
|
+
CERT_PASS = '12changeme34'
|
22
|
+
p12 = OpenSSL::PKCS12.new(File.read(CERT_PATH), CERT_PASS)
|
23
|
+
|
24
|
+
# How to get to the Splunk server that lives behind a reverse proxy
|
25
|
+
# that requires a client certificate to access
|
26
|
+
# and when a HTTP proxy is required to leave the local network.
|
27
|
+
# Edit this to match your own server setup.
|
28
|
+
config = {
|
29
|
+
:proxy => Net::HTTP::Proxy('myproxy.intranet.example.com', 80),
|
30
|
+
:scheme => :https,
|
31
|
+
:host => "externalservices.example.com",
|
32
|
+
:port => 443,
|
33
|
+
:path_prefix => '/splunk/api/',
|
34
|
+
:ssl_client_cert => p12.certificate,
|
35
|
+
:ssl_client_key => p12.key,
|
36
|
+
:username => "admin",
|
37
|
+
:password => "changeme"
|
38
|
+
}
|
39
|
+
|
40
|
+
# Create a Service logged into Splunk, and print the authentication token
|
41
|
+
# that Splunk sent us.
|
42
|
+
service0 = Splunk::connect(config)
|
43
|
+
puts "Logged in service 0. Token: #{service0.token}"
|
44
|
+
|
45
|
+
# connect is a synonym for creating a Service by hand and calling login.
|
46
|
+
service1 = Splunk::Service.new(config)
|
47
|
+
service1.login()
|
48
|
+
puts "Logged in. Token: #{service1.token}"
|
49
|
+
|
50
|
+
# However, we don't always want to call login. If we have already obtained a
|
51
|
+
# valid token, we can use it instead of a username or password. In this case
|
52
|
+
# we must create the Service manually.
|
53
|
+
token_config = {
|
54
|
+
:proxy => config[:proxy],
|
55
|
+
:scheme => config[:scheme],
|
56
|
+
:host => config[:host],
|
57
|
+
:port => config[:port],
|
58
|
+
:path_prefix => config[:path_prefix],
|
59
|
+
:ssl_client_cert => config[:ssl_client_cert],
|
60
|
+
:ssl_client_key => config[:ssl_client_key],
|
61
|
+
:token => service1.token
|
62
|
+
}
|
63
|
+
|
64
|
+
service2 = Splunk::Service.new(token_config)
|
65
|
+
puts "Theoretically logged in. Token: #{service2.token}"
|
66
|
+
|
@@ -23,6 +23,7 @@
|
|
23
23
|
#
|
24
24
|
|
25
25
|
require 'net/http'
|
26
|
+
require 'openssl'
|
26
27
|
|
27
28
|
require_relative 'splunk_http_error'
|
28
29
|
require_relative 'version'
|
@@ -33,6 +34,7 @@ module Splunk
|
|
33
34
|
DEFAULT_HOST = 'localhost'
|
34
35
|
DEFAULT_PORT = 8089
|
35
36
|
DEFAULT_SCHEME = :https
|
37
|
+
DEFAULT_PATH_PREFIX = ''
|
36
38
|
|
37
39
|
# Class encapsulating a connection to a Splunk server.
|
38
40
|
#
|
@@ -56,6 +58,10 @@ module Splunk
|
|
56
58
|
# * +:protocol+ - either :https or :http (default: :https)
|
57
59
|
# * +:namespace+ - a +Namespace+ object representing the default namespace for
|
58
60
|
# this context (default: +DefaultNamespace+)
|
61
|
+
# * +:proxy+ An instance of +Net::HTTP::Proxy+ to use as a proxy service.
|
62
|
+
# * +:path_prefix+ A path prefix that should be prepended to all URLs.
|
63
|
+
# * +:ssl_client_cert+ A +OpenSSL::X509::Certificate+ object to use as a client certificate.
|
64
|
+
# * +:ssl_client_key+ A +OpenSSL::PKey::RSA+ or +OpenSSL::PKey::DSA+ object to use as a client key.
|
59
65
|
# * +:token+ - a preauthenticated Splunk token (default: +nil+)
|
60
66
|
#
|
61
67
|
# If you specify a token, you need not specify a username or password, nor
|
@@ -80,6 +86,10 @@ module Splunk
|
|
80
86
|
# local accessor.
|
81
87
|
@namespace = args.fetch(:namespace,
|
82
88
|
Splunk::namespace(:sharing => "default"))
|
89
|
+
@proxy = args.fetch(:proxy, nil)
|
90
|
+
@path_prefix = args.fetch(:path_prefix, DEFAULT_PATH_PREFIX)
|
91
|
+
@ssl_client_cert = args.fetch(:ssl_client_cert, nil)
|
92
|
+
@ssl_client_key = args.fetch(:ssl_client_key, nil)
|
83
93
|
end
|
84
94
|
|
85
95
|
##
|
@@ -149,6 +159,29 @@ module Splunk
|
|
149
159
|
#
|
150
160
|
attr_reader :namespace
|
151
161
|
|
162
|
+
##
|
163
|
+
# An instance of +Net::HTTP::Proxy+ to use as a proxy service.
|
164
|
+
#
|
165
|
+
attr_reader :proxy
|
166
|
+
|
167
|
+
##
|
168
|
+
# The path prefix that should be prepended to all URLs.
|
169
|
+
# This is useful if the Splunk server is behind a reverse proxy server.
|
170
|
+
#
|
171
|
+
# Defaults to empty string.
|
172
|
+
#
|
173
|
+
attr_reader :path_prefix
|
174
|
+
|
175
|
+
##
|
176
|
+
# A +OpenSSL::X509::Certificate+ object to use as a client certificate.
|
177
|
+
#
|
178
|
+
attr_reader :ssl_client_cert
|
179
|
+
|
180
|
+
##
|
181
|
+
# A +OpenSSL::PKey::RSA+ or +OpenSSL::PKey::DSA+ object to use as a client key.
|
182
|
+
#
|
183
|
+
attr_reader :ssl_client_key
|
184
|
+
|
152
185
|
##
|
153
186
|
# Opens a TCP socket to the Splunk HTTP server.
|
154
187
|
#
|
@@ -307,6 +340,7 @@ module Splunk
|
|
307
340
|
url = ""
|
308
341
|
url << "#{(scheme || @scheme).to_s}://"
|
309
342
|
url << "#{host || @host}:#{(port || @port).to_s}/"
|
343
|
+
url << @path_prefix
|
310
344
|
# You would think that the second argument to URI::encode would be unnecessary
|
311
345
|
# for it to actually escape URI reserved characters. You would be wrong. It does
|
312
346
|
# have to be there, or URI::encode doesn't actually escape any characters.
|
@@ -401,11 +435,13 @@ module Splunk
|
|
401
435
|
if url.respond_to?(:hostname)
|
402
436
|
url_hostname = url.hostname
|
403
437
|
end
|
404
|
-
response = Net::HTTP::start(
|
438
|
+
response = (@proxy || Net::HTTP)::start(
|
405
439
|
url_hostname, url.port,
|
406
440
|
:use_ssl => url.scheme == 'https',
|
407
441
|
# We don't support certificates.
|
408
|
-
:verify_mode => OpenSSL::SSL::VERIFY_NONE
|
442
|
+
:verify_mode => OpenSSL::SSL::VERIFY_NONE,
|
443
|
+
:cert => @ssl_client_cert,
|
444
|
+
:key => @ssl_client_key
|
409
445
|
) do |http|
|
410
446
|
http.request(request)
|
411
447
|
end
|
data/splunk-sdk-ruby.gemspec
CHANGED
@@ -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.
|
5
|
+
gem.version = '1.0.4'
|
6
6
|
|
7
7
|
gem.authors = ['Splunk']
|
8
8
|
gem.email = ['devinfo@splunk.com']
|
@@ -12,8 +12,8 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.license = 'APL2'
|
13
13
|
|
14
14
|
gem.required_ruby_version = '>=1.9.2'
|
15
|
-
gem.add_dependency 'jruby-openssl', '
|
16
|
-
gem.
|
15
|
+
gem.add_dependency 'jruby-openssl', '>=0.7.7' if RUBY_PLATFORM == "java"
|
16
|
+
gem.add_development_dependency 'rake', '~>10'
|
17
17
|
gem.add_development_dependency 'test-unit', '~> 0'
|
18
18
|
|
19
19
|
gem.files = Dir['{lib,examples,test}/**/*',
|
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
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Splunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-25 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
|
-
type: :
|
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
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- examples/4_asynchronous_searches.rb
|
57
57
|
- examples/5_stream_data_to_splunk.rb
|
58
58
|
- examples/6_work_with_modular_inputs.rb
|
59
|
+
- examples/connect_via_reverse_proxy.rb
|
59
60
|
- examples/example_modular_inputs.spl
|
60
61
|
- examples/run_examples.rb
|
61
62
|
- lib/splunk-sdk-ruby.rb
|
@@ -142,63 +143,63 @@ require_paths:
|
|
142
143
|
- lib
|
143
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
144
145
|
requirements:
|
145
|
-
- -
|
146
|
+
- - ">="
|
146
147
|
- !ruby/object:Gem::Version
|
147
148
|
version: 1.9.2
|
148
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
150
|
requirements:
|
150
|
-
- -
|
151
|
+
- - ">="
|
151
152
|
- !ruby/object:Gem::Version
|
152
153
|
version: '0'
|
153
154
|
requirements: []
|
154
155
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.4.1
|
156
157
|
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Ruby bindings to Splunk REST layer
|
159
160
|
test_files:
|
160
|
-
- test/
|
161
|
-
- test/
|
162
|
-
- test/
|
163
|
-
- test/
|
164
|
-
- test/
|
165
|
-
- test/
|
166
|
-
- test/
|
167
|
-
- test/test_context.rb
|
161
|
+
- test/data/atom/atom_feed_with_message.xml
|
162
|
+
- test/data/atom/atom_with_feed.xml
|
163
|
+
- test/data/atom/atom_with_several_entries.xml
|
164
|
+
- test/data/atom/atom_with_simple_entries.xml
|
165
|
+
- test/data/atom/atom_without_feed.xml
|
166
|
+
- test/data/atom_test_data.json
|
167
|
+
- test/data/export/4.2.5/export_results.xml
|
168
168
|
- test/data/export/4.3.5/export_results.xml
|
169
169
|
- test/data/export/5.0.1/export_results.xml
|
170
170
|
- test/data/export/5.0.1/nonreporting.xml
|
171
|
-
- test/data/
|
172
|
-
- test/data/results/
|
173
|
-
- test/data/results/5.0.2/results.xml
|
174
|
-
- test/data/results/5.0.2/results-empty.xml
|
175
|
-
- test/data/results/5.0.2/results-empty_preview.xml
|
176
|
-
- test/data/results/4.3.5/results-preview.xml
|
177
|
-
- test/data/results/4.3.5/results.xml
|
178
|
-
- test/data/results/4.3.5/results-empty.xml
|
171
|
+
- test/data/export_test_data.json
|
172
|
+
- test/data/results/4.2.5/results-empty.xml
|
179
173
|
- test/data/results/4.2.5/results-preview.xml
|
180
174
|
- test/data/results/4.2.5/results.xml
|
181
|
-
- test/data/results/4.
|
175
|
+
- test/data/results/4.3.5/results-empty.xml
|
176
|
+
- test/data/results/4.3.5/results-preview.xml
|
177
|
+
- test/data/results/4.3.5/results.xml
|
178
|
+
- test/data/results/5.0.2/results-empty.xml
|
179
|
+
- test/data/results/5.0.2/results-empty_preview.xml
|
180
|
+
- test/data/results/5.0.2/results-preview.xml
|
181
|
+
- test/data/results/5.0.2/results.xml
|
182
182
|
- test/data/resultsreader_test_data.json
|
183
|
-
- test/
|
184
|
-
- test/data/atom/atom_with_feed.xml
|
185
|
-
- test/data/atom/atom_with_several_entries.xml
|
186
|
-
- test/data/atom/atom_feed_with_message.xml
|
187
|
-
- test/data/atom/atom_with_simple_entries.xml
|
188
|
-
- test/data/atom_test_data.json
|
189
|
-
- test/data/export_test_data.json
|
190
|
-
- test/test_collection.rb
|
191
|
-
- test/test_roles.rb
|
192
|
-
- test/test_xml_shim.rb
|
193
|
-
- test/test_atomfeed.rb
|
194
|
-
- test/testfile.txt
|
183
|
+
- test/services.server.info.xml
|
195
184
|
- test/services.xml
|
196
|
-
- test/
|
197
|
-
- test/
|
198
|
-
- test/
|
199
|
-
- test/
|
200
|
-
- test/test_inputs.rb
|
185
|
+
- test/test_atomfeed.rb
|
186
|
+
- test/test_collection.rb
|
187
|
+
- test/test_configuration_file.rb
|
188
|
+
- test/test_context.rb
|
201
189
|
- test/test_entity.rb
|
190
|
+
- test/test_helper.rb
|
191
|
+
- test/test_http_error.rb
|
202
192
|
- test/test_index.rb
|
203
|
-
- test/
|
193
|
+
- test/test_inputs.rb
|
194
|
+
- test/test_jobs.rb
|
204
195
|
- test/test_messages.rb
|
196
|
+
- test/test_modular_input_kinds.rb
|
197
|
+
- test/test_namespace.rb
|
198
|
+
- test/test_restarts.rb
|
199
|
+
- test/test_resultsreader.rb
|
200
|
+
- test/test_roles.rb
|
201
|
+
- test/test_saved_searches.rb
|
202
|
+
- test/test_service.rb
|
203
|
+
- test/test_users.rb
|
204
|
+
- test/test_xml_shim.rb
|
205
|
+
- test/testfile.txt
|