hawkular-client 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.rdoc +7 -0
- data/api_breaking_changes.rdoc +5 -0
- data/lib/hawkular/alerts/alerts_api.rb +3 -2
- data/lib/hawkular/base_client.rb +3 -2
- data/lib/hawkular/hawkular_client.rb +10 -4
- data/lib/hawkular/inventory/inventory_api.rb +6 -4
- data/lib/hawkular/operations/operations_api.rb +3 -1
- data/lib/hawkular/tokens/tokens_api.rb +3 -2
- data/lib/hawkular/version.rb +1 -1
- data/spec/integration/inventory_spec.rb +21 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_feeds_when_using_SSL_without_certificate.yml +58 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_resources_for_feed.yml +72 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0deaaa015739eac52e9e7dee6baa5af63676ead7
|
4
|
+
data.tar.gz: 86167936dc2869bc8ae120649edf36d0078fba52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c568daeb2e618ea436afc6af14ba5b98d6531e24ca6d7478b123ea868318e82700c1b4556eab69b4f9814aae57a4dc5dec029c9a6ef43c5b8828c410ff41de9e
|
7
|
+
data.tar.gz: 1e3595bf9e178c835d84bc17f5c0104a630e0c14e506f9e119807f39b2625c1e30f1428125b4df6d6a14ad141d085cb9c5c2d074a76e83c3af03893ad46fd144
|
data/CHANGES.rdoc
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
This document describes the relevant changes between releases of the
|
4
4
|
_hawkular-client_ project.
|
5
5
|
|
6
|
+
=== V 2.0.0
|
7
|
+
* This version is compatible with hawkular-services[https://github.com/hawkular/hawkular-services]
|
8
|
+
* By default no Tenant-Header is send in the requests, which is compatible with the old versions of Hawkular. However,
|
9
|
+
if the option 'tenant' is passed when creating the client, it will be sent as the header. This is the only potentialy breaking change, because
|
10
|
+
in 1.0.0, if the tenant was not specified the 'hawkular' Tenant-Header was used.
|
11
|
+
* Method for listing resources for a feed in the inventory sub-client has been fixed.
|
12
|
+
|
6
13
|
=== V 1.0.0
|
7
14
|
* This major release contains changes that <b>may break the backward compatibility</b>, more info here: link:api_breaking_changes.rdoc
|
8
15
|
* To use the client use the <code>require 'hawkular/hawkular_client'</code> instead of <code>require 'hawkular_all'</code>
|
data/api_breaking_changes.rdoc
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
== Breaking changes in the major releases
|
2
2
|
|
3
|
+
=== 2.0.0
|
4
|
+
|
5
|
+
By default no Hawkular-Tenant HTTP header is being set. If you need it (for instance for hawkular-services), provide the tenant option when creating a client.
|
6
|
+
e.g. <code>::Hawkular::Client.new(..., options: { tenant: 'hawkular' })</code>
|
7
|
+
|
3
8
|
=== 1.0.0
|
4
9
|
|
5
10
|
To use the client use the <code>require 'hawkular/hawkular_client'</code> instead of <code>require 'hawkular_all'</code>
|
@@ -12,11 +12,12 @@ module Hawkular::Alerts
|
|
12
12
|
# @param entrypoint [String] base url of Hawkular-Alerts - e.g
|
13
13
|
# http://localhost:8080/hawkular/alerts
|
14
14
|
# @param credentials [Hash{String=>String}] Hash of username, password, token(optional)
|
15
|
+
# @param options [Hash{String=>String}] Additional rest client options
|
15
16
|
class AlertsClient < Hawkular::BaseClient
|
16
|
-
def initialize(entrypoint = 'http://localhost:8080/hawkular/alerts', credentials = {})
|
17
|
+
def initialize(entrypoint = 'http://localhost:8080/hawkular/alerts', credentials = {}, options = {})
|
17
18
|
@entrypoint = entrypoint
|
18
19
|
|
19
|
-
super(entrypoint, credentials)
|
20
|
+
super(entrypoint, credentials, options)
|
20
21
|
end
|
21
22
|
|
22
23
|
# Lists defined triggers in the system
|
data/lib/hawkular/base_client.rb
CHANGED
@@ -146,8 +146,9 @@ module Hawkular
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def tenant_header
|
149
|
-
|
150
|
-
|
149
|
+
headers = {}
|
150
|
+
headers[:'Hawkular-Tenant'] = @options[:tenant] unless @options[:tenant].nil?
|
151
|
+
headers
|
151
152
|
end
|
152
153
|
|
153
154
|
def handle_fault(f)
|
@@ -16,15 +16,20 @@ module Hawkular
|
|
16
16
|
@state = hash
|
17
17
|
|
18
18
|
@inventory = Inventory::InventoryClient.create(entrypoint: "#{hash[:entrypoint]}/hawkular/inventory",
|
19
|
-
credentials: hash[:credentials]
|
19
|
+
credentials: hash[:credentials],
|
20
|
+
options: hash[:options])
|
20
21
|
|
21
22
|
@metrics = Metrics::Client.new("#{hash[:entrypoint]}/hawkular/metrics",
|
22
23
|
hash[:credentials],
|
23
24
|
hash[:options])
|
24
25
|
|
25
|
-
@alerts = Alerts::AlertsClient.new("#{hash[:entrypoint]}/hawkular/alerts",
|
26
|
+
@alerts = Alerts::AlertsClient.new("#{hash[:entrypoint]}/hawkular/alerts",
|
27
|
+
hash[:credentials],
|
28
|
+
hash[:options])
|
26
29
|
|
27
|
-
@tokens = Token::TokenClient.new(hash[:entrypoint],
|
30
|
+
@tokens = Token::TokenClient.new(hash[:entrypoint],
|
31
|
+
hash[:credentials],
|
32
|
+
hash[:options])
|
28
33
|
end
|
29
34
|
|
30
35
|
def method_missing(name, *args, &block)
|
@@ -54,7 +59,8 @@ module Hawkular
|
|
54
59
|
# this is in a dedicated method, because constructor opens the websocket connection to make the handshake
|
55
60
|
def init_operations_client
|
56
61
|
Operations::OperationsClient.new(entrypoint: @state[:entrypoint].gsub(/^https?/, 'ws'),
|
57
|
-
credentials: @state[:credentials]
|
62
|
+
credentials: @state[:credentials],
|
63
|
+
options: @state[:options])
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
@@ -14,9 +14,10 @@ module Hawkular::Inventory
|
|
14
14
|
# @param entrypoint [String] base url of Hawkular-inventory - e.g
|
15
15
|
# http://localhost:8080/hawkular/inventory
|
16
16
|
# @param credentials [Hash{String=>String}] Hash of username, password, token(optional)
|
17
|
-
|
17
|
+
# @param options [Hash{String=>String}] Additional rest client options
|
18
|
+
def initialize(entrypoint = nil, credentials = {}, options = {})
|
18
19
|
@entrypoint = entrypoint
|
19
|
-
super(entrypoint, credentials)
|
20
|
+
super(entrypoint, credentials, options)
|
20
21
|
end
|
21
22
|
|
22
23
|
# Creates a new Inventory Client
|
@@ -26,7 +27,8 @@ module Hawkular::Inventory
|
|
26
27
|
def self.create(hash)
|
27
28
|
hash[:entrypoint] ||= 'http://localhost:8080/hawkular/inventory'
|
28
29
|
hash[:credentials] ||= {}
|
29
|
-
|
30
|
+
hash[:options] ||= {}
|
31
|
+
InventoryClient.new(hash[:entrypoint], hash[:credentials], hash[:options])
|
30
32
|
end
|
31
33
|
|
32
34
|
# Retrieve the tenant id for the passed credentials.
|
@@ -74,7 +76,7 @@ module Hawkular::Inventory
|
|
74
76
|
# @return [Array<Resource>] List of resources, which can be empty.
|
75
77
|
def list_resources_for_feed(feed_id, fetch_properties = false, filter = {})
|
76
78
|
fail 'Feed id must be given' unless feed_id
|
77
|
-
the_feed = hawk_escape_id
|
79
|
+
the_feed = hawk_escape_id feed_id
|
78
80
|
ret = http_get("/feeds/#{the_feed}/resources")
|
79
81
|
to_filter = ret.map do |r|
|
80
82
|
if fetch_properties
|
@@ -47,6 +47,7 @@ module Hawkular::Operations
|
|
47
47
|
#
|
48
48
|
# @option args [String] :host base url of Hawkular - e.g http://localhost:8080
|
49
49
|
# @option args [Hash{String=>String}] :credentials Hash of (username password) or token
|
50
|
+
# @option args [Hash{String=>String}] :options Additional rest client options
|
50
51
|
# @option args [Fixnum] :wait_time Time in seconds describing how long the constructor should block - handshake
|
51
52
|
#
|
52
53
|
# @example
|
@@ -54,8 +55,9 @@ module Hawkular::Operations
|
|
54
55
|
def initialize(args)
|
55
56
|
args[:host] ||= 'localhost:8080'
|
56
57
|
args[:credentials] ||= {}
|
58
|
+
args[:options] ||= {}
|
57
59
|
args[:wait_time] ||= 0.5
|
58
|
-
super(args[:host], args[:credentials])
|
60
|
+
super(args[:host], args[:credentials], args[:options])
|
59
61
|
# note: if we start using the secured WS, change the protocol to wss://
|
60
62
|
url = "ws://#{entrypoint}/hawkular/command-gateway/ui/ws"
|
61
63
|
@ws = Simple.connect url do |client|
|
@@ -7,8 +7,9 @@ module Hawkular::Token
|
|
7
7
|
# Create a new Secret Store client
|
8
8
|
# @param entrypoint [String] base url of Hawkular - e.g http://localhost:8080
|
9
9
|
# @param credentials [Hash{String=>String}] Hash of username, password
|
10
|
-
|
11
|
-
|
10
|
+
# @param options [Hash{String=>String}] Additional rest client options
|
11
|
+
def initialize(entrypoint = 'http://localhost:8080', credentials = {}, options = {})
|
12
|
+
super(entrypoint, credentials, options)
|
12
13
|
end
|
13
14
|
|
14
15
|
# Retrieve the tenant id for the passed credentials.
|
data/lib/hawkular/version.rb
CHANGED
@@ -93,6 +93,27 @@ module Hawkular::Inventory::RSpec
|
|
93
93
|
expect(feeds.size).to be(1)
|
94
94
|
end
|
95
95
|
|
96
|
+
it 'Should list resources for feed' do
|
97
|
+
resources = @client.list_resources_for_feed feed_id
|
98
|
+
|
99
|
+
expect(resources.size).to be(2)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'Should list feeds when using SSL without certificate' do
|
103
|
+
# change this to the real credentials when updating the VCR
|
104
|
+
@state[:super_secret_username] = 'username'
|
105
|
+
@state[:super_secret_password] = 'password'
|
106
|
+
creds = { username: @state[:super_secret_username],
|
107
|
+
password: @state[:super_secret_password] }
|
108
|
+
tori_url = 'https://hawkular.torii.gva.redhat.com/hawkular/inventory'
|
109
|
+
client = Hawkular::Inventory::InventoryClient.create(entrypoint: tori_url,
|
110
|
+
credentials: creds,
|
111
|
+
options: { verify_ssl: OpenSSL::SSL::VERIFY_NONE })
|
112
|
+
feeds = client.list_feeds
|
113
|
+
|
114
|
+
expect(feeds.size).to be(1)
|
115
|
+
end
|
116
|
+
|
96
117
|
it 'Should list all the resource types' do
|
97
118
|
types = @client.list_resource_types
|
98
119
|
expect(types.size).to be(19)
|
data/spec/vcr_cassettes/Inventory/Templates/Should_list_feeds_when_using_SSL_without_certificate.yml
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<%= super_secret_username %>:<%= super_secret_password %>@hawkular.torii.gva.redhat.com/hawkular/inventory/feeds
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Hawkular-Tenant:
|
15
|
+
- hawkular
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx/1.6.3
|
27
|
+
Date:
|
28
|
+
- Fri, 27 May 2016 17:17:09 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Content-Length:
|
32
|
+
- '148'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Expires:
|
36
|
+
- '0'
|
37
|
+
Cache-Control:
|
38
|
+
- no-cache, no-store, must-revalidate
|
39
|
+
X-Powered-By:
|
40
|
+
- Undertow/1
|
41
|
+
Pragma:
|
42
|
+
- no-cache
|
43
|
+
X-Total-Count:
|
44
|
+
- '1'
|
45
|
+
Link:
|
46
|
+
- <http://hawkular.torii.gva.redhat.com/hawkular/inventory/feeds>; rel="current"
|
47
|
+
Strict-Transport-Security:
|
48
|
+
- max-age=31536000
|
49
|
+
body:
|
50
|
+
encoding: ASCII-8BIT
|
51
|
+
string: |-
|
52
|
+
[ {
|
53
|
+
"path" : "/t;0b6bda15-0d73-4375-b7a0-6318d53d7ac5/f;7ee8f677-9489-4da6-abb4-46b7e4bc228c",
|
54
|
+
"id" : "7ee8f677-9489-4da6-abb4-46b7e4bc228c"
|
55
|
+
} ]
|
56
|
+
http_version:
|
57
|
+
recorded_at: Fri, 27 May 2016 17:15:26 GMT
|
58
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://jdoe:password@localhost:8080/hawkular/inventory/feeds/<%= feed_uuid %>/resources
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Hawkular-Tenant:
|
15
|
+
- hawkular
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Expires:
|
26
|
+
- '0'
|
27
|
+
Cache-Control:
|
28
|
+
- no-cache, no-store, must-revalidate
|
29
|
+
X-Powered-By:
|
30
|
+
- Undertow/1
|
31
|
+
Server:
|
32
|
+
- WildFly/10
|
33
|
+
Pragma:
|
34
|
+
- no-cache
|
35
|
+
Date:
|
36
|
+
- Mon, 13 Jun 2016 16:29:56 GMT
|
37
|
+
X-Total-Count:
|
38
|
+
- '2'
|
39
|
+
Connection:
|
40
|
+
- keep-alive
|
41
|
+
Content-Type:
|
42
|
+
- application/json
|
43
|
+
Content-Length:
|
44
|
+
- '786'
|
45
|
+
Link:
|
46
|
+
- <http://localhost:8080/hawkular/inventory/feeds/<%= feed_uuid %>/resources>;
|
47
|
+
rel="current"
|
48
|
+
body:
|
49
|
+
encoding: ASCII-8BIT
|
50
|
+
string: |-
|
51
|
+
[ {
|
52
|
+
"path" : "/t;hawkular/f;<%= feed_uuid %>/r;platform~%2FOPERATING_SYSTEM%3D<%= feed_uuid %>_OperatingSystem",
|
53
|
+
"name" : "<%= feed_uuid %>_OperatingSystem",
|
54
|
+
"type" : {
|
55
|
+
"path" : "/t;hawkular/f;<%= feed_uuid %>/rt;Operating%20System",
|
56
|
+
"name" : "Operating System",
|
57
|
+
"id" : "Operating System"
|
58
|
+
},
|
59
|
+
"id" : "platform~/OPERATING_SYSTEM=<%= feed_uuid %>_OperatingSystem"
|
60
|
+
}, {
|
61
|
+
"path" : "/t;hawkular/f;<%= feed_uuid %>/r;Local~~",
|
62
|
+
"name" : "WildFly Server [Local]",
|
63
|
+
"type" : {
|
64
|
+
"path" : "/t;hawkular/f;<%= feed_uuid %>/rt;WildFly%20Server",
|
65
|
+
"name" : "WildFly Server",
|
66
|
+
"id" : "WildFly Server"
|
67
|
+
},
|
68
|
+
"id" : "Local~~"
|
69
|
+
} ]
|
70
|
+
http_version:
|
71
|
+
recorded_at: Mon, 13 Jun 2016 16:29:56 GMT
|
72
|
+
recorded_with: VCR 3.0.1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hawkular-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Libor Zoubek
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|
@@ -181,7 +181,8 @@ dependencies:
|
|
181
181
|
- - ">="
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
|
-
description:
|
184
|
+
description: |2
|
185
|
+
A Ruby client for Hawkular
|
185
186
|
email:
|
186
187
|
- lzoubek@redhat.com
|
187
188
|
- hrupp@redhat.com
|
@@ -309,6 +310,7 @@ files:
|
|
309
310
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_children_of_WildFly.yml
|
310
311
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_children_of_nested_resource.yml
|
311
312
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_feeds.yml
|
313
|
+
- spec/vcr_cassettes/Inventory/Templates/Should_list_feeds_when_using_SSL_without_certificate.yml
|
312
314
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_heap_metrics_for_WildFlys.yml
|
313
315
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_for_WildFlys.yml
|
314
316
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_of_given_metric_type.yml
|
@@ -317,6 +319,7 @@ files:
|
|
317
319
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_operation_definitions_of_given_resource_type.yml
|
318
320
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_recursive_children_of_WildFly.yml
|
319
321
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_relationships_of_WildFly.yml
|
322
|
+
- spec/vcr_cassettes/Inventory/Templates/Should_list_resources_for_feed.yml
|
320
323
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_types_with_bad_feed.yml
|
321
324
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_types_with_feed.yml
|
322
325
|
- spec/vcr_cassettes/Inventory/Templates/Should_not_find_an_unknown_resource.yml
|
@@ -474,6 +477,7 @@ test_files:
|
|
474
477
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_children_of_WildFly.yml
|
475
478
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_children_of_nested_resource.yml
|
476
479
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_feeds.yml
|
480
|
+
- spec/vcr_cassettes/Inventory/Templates/Should_list_feeds_when_using_SSL_without_certificate.yml
|
477
481
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_heap_metrics_for_WildFlys.yml
|
478
482
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_for_WildFlys.yml
|
479
483
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_of_given_metric_type.yml
|
@@ -482,6 +486,7 @@ test_files:
|
|
482
486
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_operation_definitions_of_given_resource_type.yml
|
483
487
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_recursive_children_of_WildFly.yml
|
484
488
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_relationships_of_WildFly.yml
|
489
|
+
- spec/vcr_cassettes/Inventory/Templates/Should_list_resources_for_feed.yml
|
485
490
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_types_with_bad_feed.yml
|
486
491
|
- spec/vcr_cassettes/Inventory/Templates/Should_list_types_with_feed.yml
|
487
492
|
- spec/vcr_cassettes/Inventory/Templates/Should_not_find_an_unknown_resource.yml
|