hawkular-client 0.2.2 → 1.0.0
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 +4 -4
- data/.rubocop.yml +3 -0
- data/.yardopts +1 -0
- data/CHANGES.rdoc +17 -4
- data/README.rdoc +15 -6
- data/api_breaking_changes.rdoc +79 -0
- data/hawkularclient.gemspec +6 -5
- data/lib/{alerts → hawkular/alerts}/alerts_api.rb +168 -7
- data/lib/{hawkular.rb → hawkular/base_client.rb} +7 -44
- data/lib/hawkular/hawkular_client.rb +60 -0
- data/lib/hawkular/hawkular_client_utils.rb +40 -0
- data/lib/{inventory → hawkular/inventory}/inventory_api.rb +167 -142
- data/lib/{metrics → hawkular/metrics}/metric_api.rb +1 -0
- data/lib/{metrics → hawkular/metrics}/metrics_client.rb +4 -4
- data/lib/{metrics → hawkular/metrics}/tenant_api.rb +0 -0
- data/lib/{metrics → hawkular/metrics}/types.rb +0 -0
- data/lib/{operations → hawkular/operations}/operations_api.rb +11 -8
- data/lib/{tokens → hawkular/tokens}/tokens_api.rb +1 -1
- data/lib/{version.rb → hawkular/version.rb} +1 -1
- data/spec/integration/alerts_spec.rb +200 -0
- data/spec/integration/hawkular_client_spec.rb +228 -0
- data/spec/integration/inventory_spec.rb +246 -160
- data/spec/integration/metric_spec.rb +52 -59
- data/spec/integration/operations_spec.rb +53 -29
- data/spec/spec_helper.rb +109 -8
- data/spec/unit/base_spec.rb +9 -0
- data/spec/unit/canonical_path_spec.rb +2 -2
- data/spec/vcr/vcr_setup.rb +6 -0
- data/spec/vcr_cassettes/Alert/Events/Should_create_an_event.yml +50 -0
- data/spec/vcr_cassettes/Alert/Groups/Should_operate_a_complex_group_trigger.yml +1726 -0
- data/spec/vcr_cassettes/Counter_metrics/Should_get_metrics_as_bucketed_results.yml +190 -0
- data/spec/vcr_cassettes/Counter_metrics/Should_get_metrics_with_limit_and_order.yml +30 -42
- data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_both_create_and_delete_feed.yml +287 -0
- data/spec/vcr_cassettes/{Inventory/Should_list_URLs.yml → HawkularClient/and_Inventory_client/Should_both_list_WildFlys.yml} +35 -33
- data/spec/vcr_cassettes/{Inventory/Should_list_types_with_bad_feed.yml → HawkularClient/and_Inventory_client/Should_both_list_types_with_bad_feed.yml} +16 -19
- data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_same_types_when_param_is_given.yml +245 -0
- data/spec/vcr_cassettes/{Inventory/Should_list_feeds.yml → HawkularClient/and_Inventory_client/Should_list_the_same_feeds.yml} +20 -20
- data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_the_same_resource_types.yml +249 -0
- data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_create_and_retrieve_tags_for_Availability.yml +155 -0
- data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_create_and_return_Availability_using_Hash_parameter.yml +155 -0
- data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_return_the_version.yml +89 -0
- data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_work_the_same_way_when_pushing_metric_data_to_non-existing_counter.yml +114 -0
- data/spec/vcr_cassettes/{Inventory/Should_list_WildFlys_with_props.yml → HawkularClient/and_Operations_client/Should_both_work_the_same_way.yml} +28 -50
- data/spec/vcr_cassettes/HawkularClient/and_Operations_client_Should_both_work_the_same_way.json +44 -0
- data/spec/vcr_cassettes/Inventory/Helpers/create_url.yml +48 -0
- data/spec/vcr_cassettes/Inventory/Helpers/generate_some_events_for_websocket.yml +4446 -0
- data/spec/vcr_cassettes/Inventory/Helpers/get_feeds.yml +54 -0
- data/spec/vcr_cassettes/Inventory/Templates/Client_should_listen_on_various_inventory_events.json +47 -0
- data/spec/vcr_cassettes/Inventory/{Should_create_a_resourcetype.yml → Templates/Client_should_listen_on_various_inventory_events.yml} +47 -61
- data/spec/vcr_cassettes/Inventory/Templates/Helpers/generate_some_events_for_websocket.yml +542 -0
- data/spec/vcr_cassettes/Inventory/{Should_List_datasources_with_no_props.yml → Templates/Should_List_datasources_with_no_props.yml} +26 -85
- data/spec/vcr_cassettes/Inventory/Templates/Should_create_a_feed.yml +54 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_create_a_feed_again.yml +164 -0
- data/spec/vcr_cassettes/Inventory/{Should_create_a_nested_resource_and_metric_on_it.yml → Templates/Should_create_a_nested_resource_and_metric_on_it.yml} +93 -74
- data/spec/vcr_cassettes/Inventory/{Should_create_a_resource_.yml → Templates/Should_create_a_resource.yml} +103 -76
- data/spec/vcr_cassettes/Inventory/{Should_create_a_resource_with_metric.yml → Templates/Should_create_a_resource_with_metric.yml} +91 -197
- data/spec/vcr_cassettes/Inventory/Templates/Should_create_a_resourcetype.yml +154 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_create_and_delete_feed.yml +145 -0
- data/spec/vcr_cassettes/Inventory/{Should_create_and_get_a_resource.yml → Templates/Should_create_and_get_a_resource.yml} +35 -20
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_URLs.yml +65 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_WildFlys.yml +61 -0
- data/spec/vcr_cassettes/Inventory/{Should_list_WildFlys.yml → Templates/Should_list_WildFlys_with_props.yml} +36 -33
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_all_the_resource_types.yml +126 -0
- data/spec/vcr_cassettes/Inventory/{Should_list_children_of_WildFly.yml → Templates/Should_list_children_of_WildFly.yml} +66 -112
- data/spec/vcr_cassettes/Inventory/{Should_list_children_of_nested_resource.yml → Templates/Should_list_children_of_nested_resource.yml} +13 -13
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_feeds.yml +54 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_heap_metrics_for_WildFlys.yml +712 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_for_WildFlys.yml +278 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_of_given_metric_type.yml +530 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_metrics_of_given_resource_type.yml +278 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_operation_definitions_of_given_resource.yml +185 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_operation_definitions_of_given_resource_type.yml +126 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_recursive_children_of_WildFly.yml +2369 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_relationships_of_WildFly.yml +415 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_types_with_bad_feed.yml +51 -0
- data/spec/vcr_cassettes/Inventory/Templates/Should_list_types_with_feed.yml +124 -0
- data/spec/vcr_cassettes/Inventory/{Should_not_find_an_unknown_resource.yml → Templates/Should_not_find_an_unknown_resource.yml} +14 -13
- data/spec/vcr_cassettes/Inventory/{Should_return_config_data_of_given_nested_resource.yml → Templates/Should_return_config_data_of_given_nested_resource.yml} +4 -4
- data/spec/vcr_cassettes/Inventory/{Should_return_config_data_of_given_resource.yml → Templates/Should_return_config_data_of_given_resource.yml} +4 -4
- data/spec/vcr_cassettes/Inventory/Tenants/Should_Get_Tenant_For_Explicit_Credentials.yml +50 -0
- data/spec/vcr_cassettes/Inventory/Tenants/Should_Get_Tenant_For_Implicit_Credentials.yml +50 -0
- data/spec/vcr_cassettes/Operation/Helpers/get_feed.yml +54 -0
- data/spec/vcr_cassettes/Operation/Helpers/get_tenant.yml +50 -0
- data/spec/vcr_cassettes/Operation/Operation/Add_JDBC_driver_should_add_the_driver.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Add_datasource_should_be_doable.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Add_deployment_should_be_doable.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Redeploy_can_be_run_multiple_times_in_parallel.json +40 -0
- data/spec/vcr_cassettes/Operation/Operation/Redeploy_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Redeploy_should_not_be_performed_if_resource_path_is_wrong.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Remove_JDBC_driver_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Remove_datasource_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Remove_deployment_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Undeploy_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/should_not_be_possible_to_perform_on_closed_client.json +12 -0
- data/spec/vcr_cassettes/Operation/Websocket_connection/should_be_established.json +9 -0
- metadata +171 -72
- data/lib/hawkular_all.rb +0 -9
- data/spec/vcr_cassettes/Inventory/Should_create_a_feed.yml +0 -107
- data/spec/vcr_cassettes/Inventory/Should_create_a_feed_again.yml +0 -211
- data/spec/vcr_cassettes/Inventory/Should_create_and_delete_feed.yml +0 -201
- data/spec/vcr_cassettes/Inventory/Should_list_all_the_resource_types.yml +0 -177
- data/spec/vcr_cassettes/Inventory/Should_list_heap_metrics_for_WildFlys.yml +0 -775
- data/spec/vcr_cassettes/Inventory/Should_list_metrics_for_WildFlys.yml +0 -333
- data/spec/vcr_cassettes/Inventory/Should_list_metrics_of_given_metric_type.yml +0 -613
- data/spec/vcr_cassettes/Inventory/Should_list_metrics_of_given_resource_type.yml +0 -333
- data/spec/vcr_cassettes/Inventory/Should_list_recursive_children_of_WildFly.yml +0 -2064
- data/spec/vcr_cassettes/Inventory/Should_list_relationships_of_WildFly.yml +0 -460
- data/spec/vcr_cassettes/Inventory/Should_list_types_with_feed.yml +0 -175
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5ef004e3d7f65c23d6519f703d3fe8cec0f02da
|
|
4
|
+
data.tar.gz: 8e3c54a206009a3e4aa9028a5dcf763156883bc4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da305496d926efb03b970a52ce00f20109dfc08a1952bfe63fd8d0d5289c156ab0ae1a1f625ed2c1720a38e30c4d45b8992b397652bcb3f22bd0dea0f216f0db
|
|
7
|
+
data.tar.gz: 3b1674b21b0fc2d4defc566f5666dbbcf923fe8752ccaf97d64256a633a2ac5541b11d6037ee3a70583227d3a0bbdb8b6d2183cf4a81ca7d389ccbed7932413c
|
data/.rubocop.yml
CHANGED
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
- CHANGES.rdoc api_breaking_changes.rdoc
|
data/CHANGES.rdoc
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
This document describes the relevant changes between releases of the
|
|
4
4
|
_hawkular-client_ project.
|
|
5
5
|
|
|
6
|
+
=== V 1.0.0
|
|
7
|
+
* This major release contains changes that <b>may break the backward compatibility</b>, more info here: link:api_breaking_changes.rdoc
|
|
8
|
+
* To use the client use the <code>require 'hawkular/hawkular_client'</code> instead of <code>require 'hawkular_all'</code>
|
|
9
|
+
* Inventory client has been rewritten to use the cannonical paths
|
|
10
|
+
* New supoort for group triggers in alert sub-client
|
|
11
|
+
* New method for creating event in the hawkular alert component
|
|
12
|
+
* New method for listing the available operation types on a resource type in inventory
|
|
13
|
+
* Hawkular-Tenant HTTP header is automatically added to each HTTP request
|
|
14
|
+
* New support for proxy option in the internal rest_client
|
|
15
|
+
* Improved VCR tests - some changing parameters in the data can be parametrized and the cassettes are stored as templates. Now, it's also possible to record those templates with <code>VCR_UPDATE=1</code>
|
|
16
|
+
* Tests are run also on ruby 2.3.0
|
|
17
|
+
* Couple of new tests
|
|
18
|
+
|
|
6
19
|
=== V 0.2.2
|
|
7
20
|
|
|
8
21
|
* Bug fix to correctly read resource info for resources that are not directly below a feed.
|
|
@@ -22,16 +35,16 @@ _hawkular-client_ project.
|
|
|
22
35
|
|
|
23
36
|
* Add support for Hawkular-Inventory and Hawkular-Alerts
|
|
24
37
|
* Reshuffling of inner classes
|
|
25
|
-
* The sub-url that is passed to
|
|
26
|
-
|
|
38
|
+
* The sub-url that is passed to +http_*+ methods is escaped via
|
|
39
|
+
+Addressable::URI.escape()+
|
|
27
40
|
|
|
28
41
|
|
|
29
42
|
=== V 0.1.2
|
|
30
43
|
|
|
31
|
-
* Fix exception handling - this was missing
|
|
44
|
+
* Fix exception handling - this was missing <code>require 'English'</code>
|
|
32
45
|
|
|
33
46
|
=== V 0.1.1
|
|
34
47
|
|
|
35
48
|
* Add VCR tests
|
|
36
|
-
* Metrics::Client.new now requires a hash for credentials
|
|
49
|
+
* +Metrics::Client.new+ now requires a hash for credentials
|
|
37
50
|
* Code cleanup and enforcement via RuboCop
|
data/README.rdoc
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
{<img src="https://coveralls.io/repos/github/hawkular/hawkular-client-ruby/badge.svg?branch=master" alt="Coverage Status" />}[https://coveralls.io/github/hawkular/hawkular-client-ruby?branch=master]
|
|
2
1
|
{<img src="https://travis-ci.org/hawkular/hawkular-client-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/hawkular/hawkular-client-ruby]
|
|
2
|
+
{<img src="https://coveralls.io/repos/github/hawkular/hawkular-client-ruby/badge.svg?branch=master" alt="Coverage Status" />}[https://coveralls.io/github/hawkular/hawkular-client-ruby?branch=master]
|
|
3
|
+
{<img src="https://codeclimate.com/github/hawkular/hawkular-client-ruby/badges/gpa.svg" />}[https://codeclimate.com/github/hawkular/hawkular-client-ruby]
|
|
3
4
|
|
|
4
5
|
= hawkular-client-ruby
|
|
5
6
|
|
|
6
7
|
A Ruby Hawkular Client.
|
|
7
8
|
|
|
9
|
+
Documentation[http://www.hawkular.org/hawkular-client-ruby/]
|
|
10
|
+
|
|
11
|
+
== Changelog
|
|
12
|
+
|
|
13
|
+
See {CHANGELOG}[link:file.CHANGES.html] for a list of changes and
|
|
14
|
+
{API-Breaking-Changes}[link:file.api_breaking_changes.html] for a list of api-breaking changes.
|
|
15
|
+
|
|
8
16
|
== Contributing to hawkular-client-ruby
|
|
9
17
|
|
|
10
18
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
|
@@ -13,7 +21,7 @@ A Ruby Hawkular Client.
|
|
|
13
21
|
* Start a feature/bugfix branch
|
|
14
22
|
* Commit and push until you are happy with your contribution
|
|
15
23
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
16
|
-
* Run your code through RuboCop (which is default when running
|
|
24
|
+
* Run your code through RuboCop (which is default when running +rake+) and fix complaints.
|
|
17
25
|
* When you open a pull request, watch out for failures on Travis.
|
|
18
26
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is
|
|
19
27
|
otherwise necessary, that is fine, but please isolate to its own commit so we can cherry-pick around it.
|
|
@@ -23,14 +31,15 @@ A Ruby Hawkular Client.
|
|
|
23
31
|
Integration tests are recorded and played against cassettes recorded with VCR
|
|
24
32
|
(http://www.relishapp.com/vcr/vcr/docs)
|
|
25
33
|
|
|
26
|
-
* Edit the endpoint properties in the file
|
|
34
|
+
* Edit the endpoint properties in the file +spec/endpoint.yml+ (user, password and host name) if needed
|
|
27
35
|
* From command line run
|
|
28
36
|
rake spec
|
|
29
|
-
* To run the tests against a live server, set VCR_OFF to 1 as in
|
|
37
|
+
* To run the tests against a live server, set +VCR_OFF+ to +1+ as in
|
|
30
38
|
VCR_OFF=1 rake spec
|
|
31
|
-
* To
|
|
39
|
+
* To update the VCR tapes that supports it, set +VCR_UPDATE+ to +1+ as in
|
|
40
|
+
VCR_UPDATE=1 rake spec
|
|
41
|
+
* To run the tests for operations against a live server using the WebSockets, set +WEBSOCKET_ON+ to +1+ as in
|
|
32
42
|
WEBSOCKET_ON=1 rake spec
|
|
33
|
-
(WebSocket communication can't be recorded by VCR)
|
|
34
43
|
|
|
35
44
|
== Logging
|
|
36
45
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
== Breaking changes in the major releases
|
|
2
|
+
|
|
3
|
+
=== 1.0.0
|
|
4
|
+
|
|
5
|
+
To use the client use the <code>require 'hawkular/hawkular_client'</code> instead of <code>require 'hawkular_all'</code>
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
While it's still possible to use individual component clients (inventory, alert, metrics, operation, token), the preferred way is to use
|
|
10
|
+
the unified client that has reference on those 'sub-clients':
|
|
11
|
+
|
|
12
|
+
<code>::Hawkular::Client.new(:entrypoint => 'http://localhost:8080', :credentials => {username: 'jdoe', password: 'password'})</code>
|
|
13
|
+
|
|
14
|
+
See the link:spec/integraion/hawkular_client_spec.rb to see more details.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
In the <code>lib/hawkular/inventory/inventory_api.rb</code> all following methods have different signatures (+old+ -> +new+):
|
|
20
|
+
|
|
21
|
+
<code>list_resources_for_type(feed_id, type, fetch_properties = false)</code>
|
|
22
|
+
->
|
|
23
|
+
<code>list_resources_for_type(type_path, fetch_properties = false, filter = {})</code>
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
<code>get_config_data_for_resource(feed_id, res_ids)</code>
|
|
27
|
+
->
|
|
28
|
+
<code>get_config_data_for_resource(resource_path)</code>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
<code>def list_child_resources(Resource parent_resource, recursive = false)</code>
|
|
32
|
+
->
|
|
33
|
+
<code>def list_child_resources(parent_resource_path, recursive = false)</code>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<code>list_relationships(Resource resource, named = nil)</code>
|
|
37
|
+
->
|
|
38
|
+
<code>list_relationships(path, named = nil)</code>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<code>list_relationships_for_feed(feed_id, named = nil)</code>
|
|
42
|
+
->
|
|
43
|
+
<code>list_relationships_for_feed(path, named = nil)</code>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<code>list_metrics_for_metric_type(feed_id, type)</code>
|
|
47
|
+
->
|
|
48
|
+
<code>list_metrics_for_metric_type(met_type_path)</code>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<code>list_metrics_for_resource_type(feed, type)</code>
|
|
52
|
+
->
|
|
53
|
+
<code>list_metrics_for_resource_type(res_type_path)</code>
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
<code>list_metrics_for_resource(Resource resource, filter = {})</code>
|
|
57
|
+
->
|
|
58
|
+
<code>list_metrics_for_resource(resource_path, filter = {})</code>
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
<code>create_resource(feed_id, type_path, resource_id, resource_name = nil, properties = {})</code>
|
|
62
|
+
->
|
|
63
|
+
<code>create_resource(type_path, resource_id, resource_name = nil, properties = {})</code>
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<code>create_resource_under_resource(feed_id, type_path, parent_resource_ids, resource_id, resource_name = nil, properties = {})</code>
|
|
67
|
+
->
|
|
68
|
+
<code>create_resource_under_resource(type_path, parent_resource_path, resource_id, resource_name = nil, properties = {})</code>
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
<code>get_resource(feed_id, res_ids, fetch_resource_config = true)</code>
|
|
72
|
+
->
|
|
73
|
+
<code>get_resource(res_path, fetch_resource_config = true)</code>
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
<code>create_metric_for_resource(feed_id, metric_id, type_path, res_ids, metric_name = nil)</code>
|
|
77
|
+
->
|
|
78
|
+
<code>create_metric_for_resource(metric_type_path, resource_path, metric_id, metric_name = nil)</code>
|
|
79
|
+
|
data/hawkularclient.gemspec
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'version'
|
|
4
|
+
require 'hawkular/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = 'hawkular-client'
|
|
8
8
|
gem.version = Hawkular::VERSION
|
|
9
|
-
gem.authors = ['Libor Zoubek', 'Heiko W. Rupp', 'Federico Simoncelli']
|
|
10
|
-
gem.email = %w(lzoubek@redhat.com hrupp@redhat.com)
|
|
9
|
+
gem.authors = ['Libor Zoubek', 'Heiko W. Rupp', 'Jirka Kremser', 'Federico Simoncelli']
|
|
10
|
+
gem.email = %w(lzoubek@redhat.com hrupp@redhat.com jkremser@redhat.com)
|
|
11
11
|
gem.homepage = 'https://github.com/hawkular/hawkular-client-ruby'
|
|
12
12
|
gem.summary = 'A Ruby client for Hawkular'
|
|
13
|
-
gem.license = '
|
|
13
|
+
gem.license = 'Apache-2.0'
|
|
14
14
|
gem.required_ruby_version = '>= 2.0.0'
|
|
15
15
|
gem.description = <<-EOS
|
|
16
16
|
A Ruby client for Hawkular
|
|
@@ -27,8 +27,9 @@ Gem::Specification.new do |gem|
|
|
|
27
27
|
gem.add_development_dependency('shoulda')
|
|
28
28
|
gem.add_development_dependency('rspec-rails', '~> 3.0')
|
|
29
29
|
gem.add_development_dependency('rake', '< 11')
|
|
30
|
+
gem.add_development_dependency('simple-websocket-vcr', '= 0.0.7')
|
|
30
31
|
gem.add_development_dependency('yard')
|
|
31
|
-
gem.add_development_dependency('webmock')
|
|
32
|
+
gem.add_development_dependency('webmock', '~> 1.24.0')
|
|
32
33
|
gem.add_development_dependency('vcr')
|
|
33
34
|
gem.add_development_dependency('rubocop', '= 0.34.2')
|
|
34
35
|
gem.add_development_dependency('coveralls')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'hawkular'
|
|
1
|
+
require 'hawkular/base_client'
|
|
2
2
|
require 'ostruct'
|
|
3
3
|
|
|
4
4
|
# Alerts module provides access to Hawkular-Alerts.
|
|
@@ -81,12 +81,95 @@ module Hawkular::Alerts
|
|
|
81
81
|
http_post 'triggers/trigger', full_trigger
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
# Creates the group trigger definition.
|
|
85
|
+
# @param [Trigger] trigger The group trigger to be created
|
|
86
|
+
# @return [Trigger] The newly created group trigger
|
|
87
|
+
def create_group_trigger(trigger)
|
|
88
|
+
ret = http_post 'triggers/groups', trigger.to_h
|
|
89
|
+
Trigger.new(ret)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Updates a given group trigger definition
|
|
93
|
+
# @param [Trigger] trigger the group trigger to be updated
|
|
94
|
+
# @return [Trigger] The updated group trigger
|
|
95
|
+
def update_group_trigger(trigger)
|
|
96
|
+
http_put "triggers/groups/#{trigger.id}/", trigger.to_h
|
|
97
|
+
get_single_trigger trigger.id, false
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Creates the group conditions definitions.
|
|
101
|
+
# @param [String] trigger_id ID of the group trigger to set conditions
|
|
102
|
+
# @param [String] trigger_mode Mode of the trigger where conditions are attached (:FIRING, :AUTORESOLVE)
|
|
103
|
+
# @param [GroupConditionsInfo] group_conditions_info the conditions to set into the group trigger with the mapping
|
|
104
|
+
# with the data_id members map
|
|
105
|
+
# @return [Array<Condition>] conditions Array of associated conditions
|
|
106
|
+
def set_group_conditions(trigger_id, trigger_mode, group_conditions_info)
|
|
107
|
+
ret = http_put "triggers/groups/#{trigger_id}/conditions/#{trigger_mode}", group_conditions_info.to_h
|
|
108
|
+
conditions = []
|
|
109
|
+
ret.each { |c| conditions.push(Trigger::Condition.new(c)) }
|
|
110
|
+
conditions
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Creates a member trigger
|
|
114
|
+
# @param [GroupMemberInfo] group_member_info the group member to be added
|
|
115
|
+
# @return [Trigger] the newly created member trigger
|
|
116
|
+
def create_member_trigger(group_member_info)
|
|
117
|
+
ret = http_post 'triggers/groups/members', group_member_info.to_h
|
|
118
|
+
Trigger.new(ret)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Detaches a member trigger from its group trigger
|
|
122
|
+
# @param [String] trigger_id ID of the member trigger to detach
|
|
123
|
+
# @return [Trigger] the orphan trigger
|
|
124
|
+
def orphan_member(trigger_id)
|
|
125
|
+
http_post "triggers/groups/members/#{trigger_id}/orphan", {}
|
|
126
|
+
get_single_trigger trigger_id, false
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Lists members of a group trigger
|
|
130
|
+
# @param [String] trigger_id ID of the group trigger to list members
|
|
131
|
+
# @param [boolean] orphans flag to include orphans
|
|
132
|
+
# @return [Array<Trigger>] Members found
|
|
133
|
+
def list_members(trigger_id, orphans = false)
|
|
134
|
+
ret = http_get "triggers/groups/#{trigger_id}/members?includeOrphans=#{orphans}"
|
|
135
|
+
ret.collect { |t| Trigger.new(t) }
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Creates a dampening for a group trigger
|
|
139
|
+
# @param [Dampening] dampening the dampening to create
|
|
140
|
+
# @return [Dampening] the newly created dampening
|
|
141
|
+
def create_group_dampening(dampening)
|
|
142
|
+
ret = http_post "triggers/groups/#{dampening.trigger_id}/dampenings", dampening.to_h
|
|
143
|
+
Trigger::Dampening.new(ret)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Updates a dampening for a group trigger
|
|
147
|
+
# @param [Dampening] dampening the dampening to update
|
|
148
|
+
# @return [Dampening] the updated dampening
|
|
149
|
+
def update_group_dampening(dampening)
|
|
150
|
+
ret = http_put "triggers/groups/#{dampening.trigger_id}/dampenings/#{dampening.dampening_id}", dampening.to_h
|
|
151
|
+
Trigger::Dampening.new(ret)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Deletes the dampening of a group trigger
|
|
155
|
+
# @param [String] trigger_id ID of the group trigger
|
|
156
|
+
# @param [String] dampening_id ID
|
|
157
|
+
def delete_group_dampening(trigger_id, dampening_id)
|
|
158
|
+
http_delete "/triggers/groups/#{trigger_id}/dampenings/#{dampening_id}"
|
|
159
|
+
end
|
|
160
|
+
|
|
84
161
|
# Deletes the trigger definition.
|
|
85
|
-
# @param [String] trigger_id
|
|
162
|
+
# @param [String] trigger_id ID of the trigger to delete
|
|
86
163
|
def delete_trigger(trigger_id)
|
|
87
164
|
http_delete "/triggers/#{trigger_id}"
|
|
88
165
|
end
|
|
89
166
|
|
|
167
|
+
# Deletes the group trigger definition.
|
|
168
|
+
# @param [String] trigger_id ID of the group trigger to delete
|
|
169
|
+
def delete_group_trigger(trigger_id)
|
|
170
|
+
http_delete "/triggers/groups/#{trigger_id}"
|
|
171
|
+
end
|
|
172
|
+
|
|
90
173
|
# Obtains action definition/plugin from the server.
|
|
91
174
|
# @param [String] action_plugin Id of the action plugin to fetch. If nil, all the plugins are fetched
|
|
92
175
|
def get_action_definition(action_plugin = nil)
|
|
@@ -210,6 +293,22 @@ module Hawkular::Alerts
|
|
|
210
293
|
query = generate_query_params(*criteria)
|
|
211
294
|
http_get('/events' + query).map { |e| Event.new(e) }
|
|
212
295
|
end
|
|
296
|
+
|
|
297
|
+
# Inject an event into Hawkular-alerts
|
|
298
|
+
# @param [String] id Id of the event must be unique
|
|
299
|
+
# @param [String] category Event category for further distinction
|
|
300
|
+
# @param [String] text Some text to the user
|
|
301
|
+
# @param [Hash<String,Object>] extras additional parameters
|
|
302
|
+
def create_event(id, category, text, extras)
|
|
303
|
+
event = {}
|
|
304
|
+
event['id'] = id
|
|
305
|
+
event['ctime'] = Time.now.to_i * 1000
|
|
306
|
+
event['category'] = category
|
|
307
|
+
event['text'] = text
|
|
308
|
+
event.merge!(extras) { |_key, v1, _v2| v1 }
|
|
309
|
+
|
|
310
|
+
http_post('/events', event)
|
|
311
|
+
end
|
|
213
312
|
end
|
|
214
313
|
|
|
215
314
|
# Representation of one Trigger
|
|
@@ -220,7 +319,7 @@ module Hawkular::Alerts
|
|
|
220
319
|
class Trigger
|
|
221
320
|
attr_accessor :id, :name, :context, :actions, :auto_disable, :auto_enable
|
|
222
321
|
attr_accessor :auto_resolve, :auto_resolve_alerts, :tags, :type
|
|
223
|
-
attr_accessor :tenant, :description, :group, :severity, :event_type
|
|
322
|
+
attr_accessor :tenant, :description, :group, :severity, :event_type, :event_category, :member_of, :data_id_map
|
|
224
323
|
attr_reader :conditions, :dampenings
|
|
225
324
|
attr_accessor :enabled, :actions
|
|
226
325
|
|
|
@@ -238,6 +337,9 @@ module Hawkular::Alerts
|
|
|
238
337
|
@auto_resolve = trigger_hash['autoResolve']
|
|
239
338
|
@auto_resolve_alerts = trigger_hash['autoResolveAlerts']
|
|
240
339
|
@event_type = trigger_hash['eventType']
|
|
340
|
+
@event_category = trigger_hash['eventCategory']
|
|
341
|
+
@member_of = trigger_hash['memberOf']
|
|
342
|
+
@data_id_map = trigger_hash['dataIdMap']
|
|
241
343
|
@tenant = trigger_hash['tenantId']
|
|
242
344
|
@description = trigger_hash['description']
|
|
243
345
|
@auto_enable = trigger_hash['autoEnable']
|
|
@@ -255,8 +357,8 @@ module Hawkular::Alerts
|
|
|
255
357
|
ret = x.to_s.split('_').collect(&:capitalize).join
|
|
256
358
|
ret[0, 1].downcase + ret[1..-1]
|
|
257
359
|
end
|
|
258
|
-
fields = [:id, :name, :enabled, :severity, :auto_resolve, :auto_resolve_alerts, :event_type,
|
|
259
|
-
:description, :auto_enable, :auto_disable, :context, :type, :tags]
|
|
360
|
+
fields = [:id, :name, :enabled, :severity, :auto_resolve, :auto_resolve_alerts, :event_type, :event_category,
|
|
361
|
+
:description, :auto_enable, :auto_disable, :context, :type, :tags, :member_of, :data_id_map]
|
|
260
362
|
|
|
261
363
|
fields.each do |field|
|
|
262
364
|
camelized_field = to_camel.call(field)
|
|
@@ -274,7 +376,7 @@ module Hawkular::Alerts
|
|
|
274
376
|
# Representing of one Condition
|
|
275
377
|
class Condition
|
|
276
378
|
attr_accessor :condition_id, :type, :operator, :threshold
|
|
277
|
-
attr_accessor :trigger_mode, :data_id
|
|
379
|
+
attr_accessor :trigger_mode, :data_id, :data2_id, :data2_multiplier
|
|
278
380
|
attr_reader :condition_set_size, :condition_set_index, :trigger_id
|
|
279
381
|
|
|
280
382
|
def initialize(cond_hash)
|
|
@@ -285,6 +387,8 @@ module Hawkular::Alerts
|
|
|
285
387
|
@type = cond_hash['type']
|
|
286
388
|
@trigger_mode = cond_hash['triggerMode']
|
|
287
389
|
@data_id = cond_hash['dataId']
|
|
390
|
+
@data2_id = cond_hash['data2Id']
|
|
391
|
+
@data2_multiplier = cond_hash['data2Multiplier']
|
|
288
392
|
@trigger_id = cond_hash['triggerId']
|
|
289
393
|
end
|
|
290
394
|
|
|
@@ -297,25 +401,82 @@ module Hawkular::Alerts
|
|
|
297
401
|
cond_hash['type'] = @type
|
|
298
402
|
cond_hash['triggerMode'] = @trigger_mode
|
|
299
403
|
cond_hash['dataId'] = @data_id
|
|
404
|
+
cond_hash['data2Id'] = @data2_id
|
|
405
|
+
cond_hash['data2Multiplier'] = @data2_multiplier
|
|
300
406
|
cond_hash['triggerId'] = @trigger_id
|
|
301
407
|
cond_hash
|
|
302
408
|
end
|
|
303
409
|
end
|
|
304
410
|
|
|
411
|
+
# Representing of one GroupConditionsInfo
|
|
412
|
+
# - The data_id_member_map should be null if the group has no members.
|
|
413
|
+
# - The data_id_member_map should be null if this is a [data-driven] group trigger.
|
|
414
|
+
# In this case the member triggers are removed and will be re-populated as incoming data demands.
|
|
415
|
+
# - For [non-data-driven] group triggers with existing members the data_id_member_map is handled as follows.
|
|
416
|
+
# For members not included in the dataIdMemberMap their most recently supplied dataIdMap will be used.
|
|
417
|
+
# This means that it is not necessary to supply mappings if the new condition set uses only dataIds found
|
|
418
|
+
# in the old condition set. If the new conditions introduce new dataIds a full dataIdMemberMap must be supplied.
|
|
419
|
+
class GroupConditionsInfo
|
|
420
|
+
attr_accessor :conditions, :data_id_member_map
|
|
421
|
+
|
|
422
|
+
def initialize(conditions)
|
|
423
|
+
@conditions = conditions
|
|
424
|
+
@data_id_member_map = {}
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def to_h
|
|
428
|
+
cond_hash = {}
|
|
429
|
+
cond_hash['conditions'] = []
|
|
430
|
+
@conditions.each { |c| cond_hash['conditions'].push(c.to_h) }
|
|
431
|
+
cond_hash['dataIdMemberMap'] = @data_id_member_map
|
|
432
|
+
cond_hash
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# Representing of one GroupMemberInfo
|
|
437
|
+
class GroupMemberInfo
|
|
438
|
+
attr_accessor :group_id, :member_id, :member_name, :member_description
|
|
439
|
+
attr_accessor :member_context, :member_tags, :data_id_map
|
|
440
|
+
|
|
441
|
+
def to_h
|
|
442
|
+
cond_hash = {}
|
|
443
|
+
cond_hash['groupId'] = @group_id
|
|
444
|
+
cond_hash['memberId'] = @member_id
|
|
445
|
+
cond_hash['memberName'] = @member_name
|
|
446
|
+
cond_hash['memberDescription'] = @member_description
|
|
447
|
+
cond_hash['memberContext'] = @member_context
|
|
448
|
+
cond_hash['memberTags'] = @member_tags
|
|
449
|
+
cond_hash['dataIdMap'] = @data_id_map
|
|
450
|
+
cond_hash
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
|
|
305
454
|
# Representation of one Dampening setting
|
|
306
455
|
class Dampening
|
|
307
|
-
attr_accessor :dampening_id, :type, :eval_true_setting, :eval_total_setting,
|
|
456
|
+
attr_accessor :dampening_id, :trigger_id, :type, :eval_true_setting, :eval_total_setting,
|
|
308
457
|
:eval_time_setting
|
|
309
458
|
attr_accessor :current_evals
|
|
310
459
|
|
|
311
460
|
def initialize(damp_hash)
|
|
312
461
|
@current_evals = {}
|
|
313
462
|
@dampening_id = damp_hash['dampeningId']
|
|
463
|
+
@trigger_id = damp_hash['triggerId']
|
|
314
464
|
@type = damp_hash['type']
|
|
315
465
|
@eval_true_setting = damp_hash['evalTrueSetting']
|
|
316
466
|
@eval_total_setting = damp_hash['evalTotalSetting']
|
|
317
467
|
@eval_time_setting = damp_hash['evalTimeSetting']
|
|
318
468
|
end
|
|
469
|
+
|
|
470
|
+
def to_h
|
|
471
|
+
cond_hash = {}
|
|
472
|
+
cond_hash['dampeningId'] = @dampening_id
|
|
473
|
+
cond_hash['triggerId'] = @trigger_id
|
|
474
|
+
cond_hash['type'] = @type
|
|
475
|
+
cond_hash['evalTrueSetting'] = @eval_true_setting
|
|
476
|
+
cond_hash['evalTotalSetting'] = @eval_total_setting
|
|
477
|
+
cond_hash['evalTimeSetting'] = @eval_time_setting
|
|
478
|
+
cond_hash
|
|
479
|
+
end
|
|
319
480
|
end
|
|
320
481
|
|
|
321
482
|
class Action
|