hawkular-client 2.9.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (340) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.rdoc +27 -0
  3. data/README.rdoc +14 -14
  4. data/lib/hawkular/alerts/alerts_api.rb +43 -7
  5. data/lib/hawkular/client_utils.rb +0 -3
  6. data/lib/hawkular/hawkular_client.rb +1 -1
  7. data/lib/hawkular/inventory/entities.rb +55 -19
  8. data/lib/hawkular/inventory/inventory_api.rb +313 -412
  9. data/lib/hawkular/metrics/metric_api.rb +5 -2
  10. data/lib/hawkular/operations/operations_api.rb +0 -8
  11. data/lib/hawkular/tokens/tokens_api.rb +0 -3
  12. data/lib/hawkular/version.rb +1 -1
  13. metadata +3 -647
  14. data/.coveralls.yml +0 -1
  15. data/.gitignore +0 -56
  16. data/.rubocop.yml +0 -32
  17. data/.travis.yml +0 -20
  18. data/.travis/start_hawkular_services.sh +0 -21
  19. data/.travis/wait_for_services.rb +0 -39
  20. data/.yardopts +0 -1
  21. data/Gemfile +0 -2
  22. data/Rakefile +0 -20
  23. data/api_breaking_changes.rdoc +0 -84
  24. data/docker-compose.yml +0 -17
  25. data/hawkularclient.gemspec +0 -43
  26. data/spec/README.rdoc +0 -62
  27. data/spec/integration/alert-resources/alerts-test-data.json +0 -40
  28. data/spec/integration/alert-resources/events-test-data.json +0 -78
  29. data/spec/integration/alert-resources/triggers-test-data.json +0 -66
  30. data/spec/integration/alerts_spec.rb +0 -774
  31. data/spec/integration/env_config_spec.rb +0 -39
  32. data/spec/integration/hawkular_client_spec.rb +0 -304
  33. data/spec/integration/hello-world-definitions.json +0 -45
  34. data/spec/integration/inventory_spec.rb +0 -680
  35. data/spec/integration/logger_spec.rb +0 -36
  36. data/spec/integration/metric_spec.rb +0 -953
  37. data/spec/integration/operations_spec.rb +0 -591
  38. data/spec/integration/tokens_spec.rb +0 -49
  39. data/spec/resources/driver.jar +0 -0
  40. data/spec/resources/sample.war +0 -0
  41. data/spec/spec_helper.rb +0 -336
  42. data/spec/unit/base_spec.rb +0 -256
  43. data/spec/unit/canonical_path_spec.rb +0 -102
  44. data/spec/unit/client_spec.rb +0 -55
  45. data/spec/unit/deprecations_spec.rb +0 -19
  46. data/spec/vcr/vcr_setup.rb +0 -16
  47. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_acknowledge_an_alert.yml +0 -205
  48. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_add_tags_to_existing_alert.yml +0 -210
  49. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_fetch_single_alert.yml +0 -108
  50. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_list_alerts.yml +0 -59
  51. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_list_alerts_for_trigger.yml +0 -58
  52. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_list_alerts_for_unknown_trigger.yml +0 -50
  53. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_list_open_alerts.yml +0 -59
  54. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_remove_tags_from_existing_alert.yml +0 -257
  55. data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_resolve_an_alert.yml +0 -207
  56. data/spec/vcr_cassettes/Alert/Alerts/Templates/setup.yml +0 -255
  57. data/spec/vcr_cassettes/Alert/Alerts/Templates/setup_cleanup.yml +0 -302
  58. data/spec/vcr_cassettes/Alert/EndToEnd/Templates/Should_create_and_fire_a_trigger.yml +0 -527
  59. data/spec/vcr_cassettes/Alert/Events/Templates/Should_create_an_event.yml +0 -101
  60. data/spec/vcr_cassettes/Alert/Events/Templates/Should_delete_an_event.yml +0 -148
  61. data/spec/vcr_cassettes/Alert/Events/Templates/Should_list_events.yml +0 -91
  62. data/spec/vcr_cassettes/Alert/Events/Templates/Should_list_events_using_criteria.yml +0 -60
  63. data/spec/vcr_cassettes/Alert/Events/Templates/Should_not_list_events_using_criteria.yml +0 -50
  64. data/spec/vcr_cassettes/Alert/Events/Templates/setup.yml +0 -615
  65. data/spec/vcr_cassettes/Alert/Events/Templates/setup_cleanup.yml +0 -567
  66. data/spec/vcr_cassettes/Alert/Groups/Templates/Should_operate_a_complex_group_trigger.yml +0 -1882
  67. data/spec/vcr_cassettes/Alert/Templates/Should_return_the_version.yml +0 -42
  68. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_List_Triggers.yml +0 -55
  69. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_List_Triggers_for_ID.yml +0 -56
  70. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_List_Triggers_for_Tag.yml +0 -56
  71. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_List_Triggers_for_Tags.yml +0 -56
  72. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_bulk_load_triggers.yml +0 -243
  73. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_create_a_basic_trigger_with_action.yml +0 -386
  74. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_create_a_firing_ALL_ANY_trigger.yml +0 -483
  75. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_create_an_action.yml +0 -146
  76. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_get_a_single_Trigger_with_conditions.yml +0 -144
  77. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_get_a_single_metric_Trigger.yml +0 -50
  78. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_get_the_action_definitions.yml +0 -228
  79. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_not_create_an_action_for_unknown_plugin.yml +0 -50
  80. data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_not_create_an_action_for_unknown_properties.yml +0 -100
  81. data/spec/vcr_cassettes/Alert/Triggers/Templates/setup.yml +0 -52
  82. data/spec/vcr_cassettes/Alert/Triggers/Templates/setup_cleanup.yml +0 -285
  83. data/spec/vcr_cassettes/HawkularClient/Should_err_on_bad_credentials.yml +0 -42
  84. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_both_create_and_delete_feed.yml +0 -317
  85. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_both_list_WildFlys.yml +0 -103
  86. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_both_list_types_with_bad_feed.yml +0 -103
  87. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_same_types_when_param_is_given.yml +0 -325
  88. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_the_same_feeds.yml +0 -117
  89. data/spec/vcr_cassettes/HawkularClient/and_Inventory_client/Should_list_the_same_resource_types.yml +0 -111
  90. data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_create_and_retrieve_tags_for_Availability.yml +0 -155
  91. data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_create_and_return_Availability_using_Hash_parameter.yml +0 -155
  92. data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_return_the_version.yml +0 -89
  93. data/spec/vcr_cassettes/HawkularClient/and_Metrics_client/Should_both_work_the_same_way_when_pushing_metric_data_to_non-existing_counter.yml +0 -114
  94. data/spec/vcr_cassettes/HawkularClient/and_Operations_client/Should_both_work_the_same_way.yml +0 -158
  95. data/spec/vcr_cassettes/HawkularClient/and_Operations_client/Should_work_initializing_with_URI.yml +0 -48
  96. data/spec/vcr_cassettes/HawkularClient/and_Operations_client_Should_both_work_the_same_way.json +0 -44
  97. data/spec/vcr_cassettes/HawkularClient/and_Operations_client_Should_work_initializing_with_URI.json +0 -9
  98. data/spec/vcr_cassettes/HawkularClient/and_URIs_as_input/Should_work_with_URI.yml +0 -169
  99. data/spec/vcr_cassettes/HawkularClient/and_URIs_as_input/Should_work_with_URI_on_metrics_client.yml +0 -42
  100. data/spec/vcr_cassettes/Inventory/NonSecure/Connection/Templates/Should_err_on_bad_credentials.yml +0 -44
  101. data/spec/vcr_cassettes/Inventory/NonSecure/Tenants/Templates/Should_Get_Tenant_For_Explicit_Credentials.yml +0 -101
  102. data/spec/vcr_cassettes/Inventory/NonSecure/Tenants/Templates/Should_Get_Tenant_For_Implicit_Credentials.yml +0 -101
  103. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Client_should_listen_on_various_inventory_events.json +0 -47
  104. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Client_should_listen_on_various_inventory_events.yml +0 -207
  105. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Helpers/create_url.yml +0 -52
  106. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Helpers/generate_some_events_for_websocket.yml +0 -411
  107. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Helpers/get_feeds.yml +0 -62
  108. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_List_datasources_with_no_props.yml +0 -133
  109. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_a_feed.yml +0 -59
  110. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_a_feed_again.yml +0 -181
  111. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_a_nested_resource_and_metric_on_it.yml +0 -664
  112. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_a_resource.yml +0 -360
  113. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_a_resource_with_metric.yml +0 -846
  114. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_a_resourcetype.yml +0 -169
  115. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_and_delete_feed.yml +0 -166
  116. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_create_and_get_a_resource.yml +0 -420
  117. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_get_resource_with_its_configurations.yml +0 -132
  118. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_have_a_consistent_behaviour_when_creating_an_already_existing_resource.yml +0 -714
  119. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_have_the_same_requested_metric_type_id.yml +0 -73
  120. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_URLs.yml +0 -90
  121. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_WildFlys.yml +0 -70
  122. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_WildFlys_with_props.yml +0 -138
  123. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_all_the_resource_types.yml +0 -59
  124. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_children_of_WildFly.yml +0 -333
  125. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_children_of_nested_resource.yml +0 -180
  126. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_feeds.yml +0 -62
  127. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_heap_metrics_for_WildFlys.yml +0 -943
  128. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_metrics_for_WildFlys.yml +0 -361
  129. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_metrics_of_given_metric_type.yml +0 -94
  130. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_metrics_of_given_resource_type.yml +0 -294
  131. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_operation_definitions_of_given_resource.yml +0 -871
  132. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_operation_definitions_of_given_resource_type.yml +0 -740
  133. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_recursive_children_of_WildFly.yml +0 -1117
  134. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_relationships_of_WildFly.yml +0 -393
  135. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_resources_for_feed.yml +0 -84
  136. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_types_with_bad_feed.yml +0 -55
  137. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_list_types_with_feed.yml +0 -166
  138. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_not_find_an_unknown_resource.yml +0 -59
  139. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_return_config_data_of_given_nested_resource.yml +0 -66
  140. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_return_config_data_of_given_resource.yml +0 -71
  141. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_return_data_from_get_entity.yml +0 -230
  142. data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_return_the_version.yml +0 -50
  143. data/spec/vcr_cassettes/Inventory/Secure/Connection/Templates/Should_err_on_bad_credentials.yml +0 -44
  144. data/spec/vcr_cassettes/Inventory/Secure/Tenants/Templates/Should_Get_Tenant_For_Explicit_Credentials.yml +0 -101
  145. data/spec/vcr_cassettes/Inventory/Secure/Tenants/Templates/Should_Get_Tenant_For_Implicit_Credentials.yml +0 -101
  146. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Client_should_listen_on_various_inventory_events.json +0 -47
  147. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Client_should_listen_on_various_inventory_events.yml +0 -207
  148. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Helpers/create_url.yml +0 -52
  149. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Helpers/generate_some_events_for_websocket.yml +0 -411
  150. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Helpers/get_feeds.yml +0 -62
  151. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_List_datasources_with_no_props.yml +0 -133
  152. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_a_feed.yml +0 -59
  153. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_a_feed_again.yml +0 -181
  154. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_a_nested_resource_and_metric_on_it.yml +0 -664
  155. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_a_resource.yml +0 -360
  156. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_a_resource_with_metric.yml +0 -846
  157. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_a_resourcetype.yml +0 -169
  158. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_and_delete_feed.yml +0 -166
  159. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_create_and_get_a_resource.yml +0 -420
  160. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_get_resource_with_its_configurations.yml +0 -132
  161. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_have_the_same_requested_metric_type_id.yml +0 -73
  162. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_URLs.yml +0 -90
  163. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_WildFlys.yml +0 -70
  164. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_WildFlys_with_props.yml +0 -138
  165. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_all_the_resource_types.yml +0 -59
  166. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_children_of_WildFly.yml +0 -333
  167. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_children_of_nested_resource.yml +0 -180
  168. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_feeds.yml +0 -62
  169. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_heap_metrics_for_WildFlys.yml +0 -943
  170. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_metrics_for_WildFlys.yml +0 -361
  171. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_metrics_of_given_metric_type.yml +0 -90
  172. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_metrics_of_given_resource_type.yml +0 -294
  173. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_operation_definitions_of_given_resource.yml +0 -871
  174. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_operation_definitions_of_given_resource_type.yml +0 -740
  175. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_recursive_children_of_WildFly.yml +0 -1117
  176. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_relationships_of_WildFly.yml +0 -393
  177. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_resources_for_feed.yml +0 -84
  178. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_types_with_bad_feed.yml +0 -55
  179. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_list_types_with_feed.yml +0 -166
  180. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_not_find_an_unknown_resource.yml +0 -59
  181. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_return_config_data_of_given_nested_resource.yml +0 -66
  182. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_return_config_data_of_given_resource.yml +0 -71
  183. data/spec/vcr_cassettes/Inventory/Secure/inventory_0_17/Templates/Should_return_the_version.yml +0 -50
  184. data/spec/vcr_cassettes/Inventory/Templates/Should_list_feeds_when_using_SSL_without_certificate.yml +0 -114
  185. data/spec/vcr_cassettes/Inventory/inventory_0_17/Templates/Should_get_resource_with_its_configurations.yml +0 -132
  186. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Get_metric_definition_by_id.yml +0 -51
  187. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Retrieve_metric_rate_points.yml +0 -92
  188. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Should_create_Availability_definition.yml +0 -101
  189. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Should_create_Counter_definition.yml +0 -101
  190. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Should_create_gauge_definition.yml +0 -101
  191. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Should_push_metric_data_to_existing_gauge.yml +0 -50
  192. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Should_update_tags_for_Availability_definition.yml +0 -146
  193. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/Should_update_tags_for_gauge_definition.yml +0 -146
  194. data/spec/vcr_cassettes/Metrics/NonSecure/ID_with_special_characters/Templates/setup_client.yml +0 -44
  195. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Availability_metrics/Should_create_Availability_definition_using_MetricDefinition_parameter.yml +0 -83
  196. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Availability_metrics/Should_create_and_return_Availability_using_Hash_parameter.yml +0 -83
  197. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Availability_metrics/Should_push_metric_data_to_non-existing_Availability.yml +0 -120
  198. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Availability_metrics/Should_update_tags_for_Availability_definition.yml +0 -200
  199. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Counter_metrics/Should_create_and_return_counter_using_Hash_parameter.yml +0 -83
  200. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Counter_metrics/Should_create_counter_definition_using_MetricDefinition_parameter.yml +0 -83
  201. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Counter_metrics/Should_get_metrics_as_bucketed_results.yml +0 -200
  202. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Counter_metrics/Should_push_metric_data_to_existing_counter.yml +0 -237
  203. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Counter_metrics/Should_push_metric_data_to_non-existing_counter.yml +0 -120
  204. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Gauge_metrics/Should_create_gauge_definition_using_Hash.yml +0 -83
  205. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Gauge_metrics/Should_create_gauge_definition_using_MetricDefinition.yml +0 -83
  206. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Gauge_metrics/Should_push_metric_data_to_existing_gauge.yml +0 -237
  207. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Gauge_metrics/Should_push_metric_data_to_non-existing_gauge.yml +0 -120
  208. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Gauge_metrics/Should_return_periods.yml +0 -81
  209. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Gauge_metrics/Should_update_tags_for_gauge_definition.yml +0 -200
  210. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Mixed_metrics/Should_send_mixed_metric_request.yml +0 -270
  211. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Mixed_metrics/Should_send_mixed_metric_request_of_a_single_type.yml +0 -237
  212. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Simple/Should_be_Cool.yml +0 -82
  213. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Status/Should_return_the_version.yml +0 -42
  214. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_0_8_0/Templates/Tenants/Should_create_and_return_tenant.yml +0 -83
  215. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/All_Tags_for_metrics/Should_fetch_all_metric_tags_for_metrics_definitions.yml +0 -434
  216. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/All_Tags_for_metrics/Should_fetch_all_metrics_with_some_tags.yml +0 -1251
  217. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Availability_metrics/Should_create_Availability_definition_using_MetricDefinition_parameter.yml +0 -99
  218. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Availability_metrics/Should_create_and_return_Availability_using_Hash_parameter.yml +0 -99
  219. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Availability_metrics/Should_group_contiguous_values.yml +0 -138
  220. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Availability_metrics/Should_push_metric_data_to_non-existing_Availability.yml +0 -144
  221. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Availability_metrics/Should_update_tags_for_Availability_definition.yml +0 -240
  222. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Availability_metrics/setup_client.yml +0 -44
  223. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Counter_metrics/Should_create_and_return_counter_using_Hash_parameter.yml +0 -99
  224. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Counter_metrics/Should_create_counter_definition_using_MetricDefinition_parameter.yml +0 -99
  225. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Counter_metrics/Should_get_metrics_as_bucketed_results.yml +0 -240
  226. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Counter_metrics/Should_get_metrics_with_limit_and_order.yml +0 -328
  227. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Counter_metrics/Should_push_metric_data_to_existing_counter.yml +0 -281
  228. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Counter_metrics/Should_push_metric_data_to_non-existing_counter.yml +0 -144
  229. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Counter_metrics/setup_client.yml +0 -44
  230. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_create_gauge_definition_using_Hash.yml +0 -99
  231. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_create_gauge_definition_using_MetricDefinition.yml +0 -99
  232. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_push_metric_data_to_existing_gauge.yml +0 -281
  233. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_push_metric_data_to_non-existing_gauge.yml +0 -144
  234. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_return_periods.yml +0 -97
  235. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_return_platform_memory.yml +0 -196
  236. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_return_platform_memory_def.yml +0 -197
  237. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/Should_update_tags_for_gauge_definition.yml +0 -240
  238. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Gauge_metrics/setup_client.yml +0 -44
  239. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Mixed_metrics/Should_fetch_rate_stats_for_mixed_metric.yml +0 -328
  240. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Mixed_metrics/Should_fetch_stats_for_mixed_metric.yml +0 -363
  241. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Mixed_metrics/Should_requests_raw_data_for_multiple_metrics.yml +0 -414
  242. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Mixed_metrics/Should_send_mixed_metric_request.yml +0 -314
  243. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Mixed_metrics/Should_send_mixed_metric_request_of_a_single_type.yml +0 -285
  244. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Mixed_metrics/setup_client.yml +0 -44
  245. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/No_Tenant/Should_fail.yml +0 -89
  246. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Simple/Should_be_Cool.yml +0 -48
  247. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Status/Should_return_the_version.yml +0 -85
  248. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/String_metrics/Should_create_string_definition_using_Hash.yml +0 -99
  249. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/String_metrics/Should_create_string_definition_using_MetricDefinition.yml +0 -99
  250. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/String_metrics/Should_push_metric_data_to_existing_string.yml +0 -281
  251. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/String_metrics/Should_push_metric_data_to_non-existing_string.yml +0 -144
  252. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/String_metrics/setup_client.yml +0 -44
  253. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Tags_Metrics/setup_client.yml +0 -44
  254. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Tenants/Should_create_and_return_tenant.yml +0 -103
  255. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Tenants/setup_client.yml +0 -44
  256. data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/setup_client.yml +0 -44
  257. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Get_metric_definition_by_id.yml +0 -51
  258. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Retrieve_metric_rate_points.yml +0 -92
  259. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Should_create_Availability_definition.yml +0 -101
  260. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Should_create_Counter_definition.yml +0 -101
  261. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Should_create_gauge_definition.yml +0 -101
  262. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Should_push_metric_data_to_existing_gauge.yml +0 -50
  263. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Should_update_tags_for_Availability_definition.yml +0 -146
  264. data/spec/vcr_cassettes/Metrics/Secure/ID_with_special_characters/Templates/Should_update_tags_for_gauge_definition.yml +0 -146
  265. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Availability_metrics/Should_create_Availability_definition_using_MetricDefinition_parameter.yml +0 -99
  266. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Availability_metrics/Should_create_and_return_Availability_using_Hash_parameter.yml +0 -99
  267. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Availability_metrics/Should_group_contiguous_values.yml +0 -97
  268. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Availability_metrics/Should_push_metric_data_to_non-existing_Availability.yml +0 -144
  269. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Availability_metrics/Should_update_tags_for_Availability_definition.yml +0 -240
  270. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Counter_metrics/Should_create_and_return_counter_using_Hash_parameter.yml +0 -99
  271. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Counter_metrics/Should_create_counter_definition_using_MetricDefinition_parameter.yml +0 -99
  272. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Counter_metrics/Should_get_metrics_as_bucketed_results.yml +0 -240
  273. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Counter_metrics/Should_get_metrics_with_limit_and_order.yml +0 -328
  274. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Counter_metrics/Should_push_metric_data_to_existing_counter.yml +0 -281
  275. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Counter_metrics/Should_push_metric_data_to_non-existing_counter.yml +0 -144
  276. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_create_gauge_definition_using_Hash.yml +0 -99
  277. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_create_gauge_definition_using_MetricDefinition.yml +0 -99
  278. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_push_metric_data_to_existing_gauge.yml +0 -281
  279. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_push_metric_data_to_non-existing_gauge.yml +0 -144
  280. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_return_periods.yml +0 -97
  281. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_return_platform_memory.yml +0 -50
  282. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_return_platform_memory_def.yml +0 -51
  283. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Gauge_metrics/Should_update_tags_for_gauge_definition.yml +0 -240
  284. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Mixed_metrics/Should_fetch_stats_for_mixed_metric.yml +0 -364
  285. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Mixed_metrics/Should_requests_raw_data_for_multiple_metrics.yml +0 -373
  286. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Mixed_metrics/Should_send_mixed_metric_request.yml +0 -314
  287. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Mixed_metrics/Should_send_mixed_metric_request_of_a_single_type.yml +0 -285
  288. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/No_Tenant/Should_fail.yml +0 -50
  289. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Simple/Should_be_Cool.yml +0 -48
  290. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Status/Should_return_the_version.yml +0 -44
  291. data/spec/vcr_cassettes/Metrics/Secure/metrics_services/Templates/Tenants/Should_create_and_return_tenant.yml +0 -99
  292. data/spec/vcr_cassettes/New_API_Counter_metrics/Should_get_metrics_as_bucketed_results.yml +0 -230
  293. data/spec/vcr_cassettes/New_API_Mixed_metrics/Should_send_mixed_metric_request.yml +0 -300
  294. data/spec/vcr_cassettes/Operation/NonSecure/Helpers/Templates/agent_properties.yml +0 -124
  295. data/spec/vcr_cassettes/Operation/NonSecure/Helpers/Templates/get_feed.yml +0 -61
  296. data/spec/vcr_cassettes/Operation/NonSecure/Helpers/Templates/get_tenant.yml +0 -55
  297. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Add_JDBC_driver_should_add_the_driver.json +0 -23
  298. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Add_XA_datasource_should_be_doable.json +0 -23
  299. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Add_deployment_should_be_doable.json +0 -23
  300. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Add_non-XA_datasource_should_be_doable.json +0 -23
  301. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Disable_should_be_performed_and_eventually_respond_with_success.json +0 -23
  302. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Remove_JDBC_driver_should_be_performed_and_eventually_respond_with_success.json +0 -23
  303. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Remove_datasource_should_be_performed_and_eventually_respond_with_success.json +0 -23
  304. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Restart_can_be_run_multiple_times_in_parallel.json +0 -32
  305. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Restart_should_be_performed_and_eventually_respond_with_success.json +0 -23
  306. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Restart_should_not_be_performed_if_resource_path_is_wrong.json +0 -23
  307. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Undeploy_deployment_should_be_performed_and_eventually_respond_with_success.json +0 -23
  308. data/spec/vcr_cassettes/Operation/NonSecure/Operation/Update_collection_intervals_should_be_performed_and_eventually_respond_with_success.json +0 -23
  309. data/spec/vcr_cassettes/Operation/NonSecure/Operation/should_not_be_possible_to_perform_on_closed_client.json +0 -12
  310. data/spec/vcr_cassettes/Operation/NonSecure/Websocket_connection/should_bail_with_hash_property_error_because_no_callback_at_all.json +0 -9
  311. data/spec/vcr_cassettes/Operation/NonSecure/Websocket_connection/should_bail_with_hash_property_error_because_no_error-callback_.json +0 -9
  312. data/spec/vcr_cassettes/Operation/NonSecure/Websocket_connection/should_bail_with_no_host.json +0 -3
  313. data/spec/vcr_cassettes/Operation/NonSecure/Websocket_connection/should_be_established.json +0 -9
  314. data/spec/vcr_cassettes/Operation/NonSecure/Websocket_connection/should_be_established_via_entrypoint.json +0 -9
  315. data/spec/vcr_cassettes/Operation/NonSecure/Websocket_connection/should_run_into_error_callback.json +0 -18
  316. data/spec/vcr_cassettes/Operation/NonSecure/Websocket_connection/should_run_into_error_callback_because_bad_hash_parameters.json +0 -13
  317. data/spec/vcr_cassettes/Operation/Secure/Helpers/Templates/get_feed.yml +0 -61
  318. data/spec/vcr_cassettes/Operation/Secure/Helpers/Templates/get_tenant.yml +0 -55
  319. data/spec/vcr_cassettes/Operation/Secure/Operation/Add_JDBC_driver_should_add_the_driver.json +0 -23
  320. data/spec/vcr_cassettes/Operation/Secure/Operation/Add_datasource_should_be_doable.json +0 -23
  321. data/spec/vcr_cassettes/Operation/Secure/Operation/Add_deployment_should_be_doable.json +0 -23
  322. data/spec/vcr_cassettes/Operation/Secure/Operation/Disable_should_be_performed_and_eventually_respond_with_success.json +0 -23
  323. data/spec/vcr_cassettes/Operation/Secure/Operation/Remove_JDBC_driver_should_be_performed_and_eventually_respond_with_success.json +0 -23
  324. data/spec/vcr_cassettes/Operation/Secure/Operation/Remove_datasource_should_be_performed_and_eventually_respond_with_success.json +0 -23
  325. data/spec/vcr_cassettes/Operation/Secure/Operation/Restart_can_be_run_multiple_times_in_parallel.json +0 -32
  326. data/spec/vcr_cassettes/Operation/Secure/Operation/Restart_should_be_performed_and_eventually_respond_with_success.json +0 -23
  327. data/spec/vcr_cassettes/Operation/Secure/Operation/Restart_should_not_be_performed_if_resource_path_is_wrong.json +0 -23
  328. data/spec/vcr_cassettes/Operation/Secure/Operation/Undeploy_deployment_should_be_performed_and_eventually_respond_with_success.json +0 -23
  329. data/spec/vcr_cassettes/Operation/Secure/Operation/should_not_be_possible_to_perform_on_closed_client.json +0 -12
  330. data/spec/vcr_cassettes/Operation/Secure/Websocket_connection/should_bail_with_hash_property_error_because_no_callback_at_all.json +0 -9
  331. data/spec/vcr_cassettes/Operation/Secure/Websocket_connection/should_bail_with_hash_property_error_because_no_error-callback_.json +0 -9
  332. data/spec/vcr_cassettes/Operation/Secure/Websocket_connection/should_bail_with_no_host.json +0 -3
  333. data/spec/vcr_cassettes/Operation/Secure/Websocket_connection/should_be_established.json +0 -9
  334. data/spec/vcr_cassettes/Operation/Secure/Websocket_connection/should_be_established_via_entrypoint.json +0 -9
  335. data/spec/vcr_cassettes/Operation/Secure/Websocket_connection/should_run_into_error_callback.json +0 -18
  336. data/spec/vcr_cassettes/Operation/Secure/Websocket_connection/should_run_into_error_callback_because_bad_hash_parameters.json +0 -13
  337. data/spec/vcr_cassettes/Tokens/Should_be_able_to_create_a_new_token_for_an_actual_user.yml +0 -57
  338. data/spec/vcr_cassettes/Tokens/Should_be_able_to_list_the_available_tokens.yml +0 -49
  339. data/spec/vcr_cassettes/Tokens/Should_get_a_401_when_attempting_to_create_a_token_with_a_wrong_password.yml +0 -56
  340. data/spec/vcr_cassettes/Tokens/Should_get_a_401_when_attempting_to_create_a_token_without_a_password.yml +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f90b7acb9dd7b68be8eee6d0bb3de9dbf7741889
4
- data.tar.gz: 6949105936e1945f288c7580ac79e12bfab21138
3
+ metadata.gz: e76b799552626ef0cdf91e857c5d3adaf87eb895
4
+ data.tar.gz: 60e0412e27855f6938372e48cf4b5a891636558f
5
5
  SHA512:
6
- metadata.gz: 4dda4fc49377010414493c0fd44ff4ff2fd26dfaa9bd8501abdc4a786f883cfaba563c1bfec1980238d6abd548289d33f56f071372d77619e4a665b0761cc032
7
- data.tar.gz: 493b2e043dede0926bee0bb65ca09f51ae8913619ace6e3dbd07985fb895ec0cef661b8ba953b1ae39d17ed81b4e754df4d318004ea17a0edc618b2851b586cd
6
+ metadata.gz: 58308a3a777a01ee4d24def939d59a79b520e23632d78103f198af1b38812561699d749ccfd242fdcf64ebb25453cd8b0060f1976c123c8f4b3d46a3dc1487b2
7
+ data.tar.gz: c2321e151cf25093156ccf8c070041ac7759d2c6ed1e824af9bf631546078324206bf0e46465a4e9a39fc4b2e7fadea1673a20e1479e47b4520bcbf2a3587c48
data/CHANGES.rdoc CHANGED
@@ -3,6 +3,33 @@
3
3
  This document describes the relevant changes between releases of the
4
4
  _hawkular-client_ project.
5
5
 
6
+
7
+ === V 3.0.0
8
+ * Starting this version the older Hawkular Services (prior version 0.36.0.Final, excluding) are not compatible
9
+ * We added support for multitenancy
10
+ * We removed the deprecated API mentioned in the previous release notes
11
+ * A lot of methods in the inventory client have been changed or removed, here is the list:
12
+ 1. <code>get_tenant</code> - removed
13
+ 2. <code>list_relationships</code> - removed
14
+ 3. <code>list_relationships_for_feed</code> - removed
15
+ 4. <code>get_entity</code> - removed
16
+ 5. <code>delete_feed</code> - removed
17
+ 6. <code>create_feed</code> - removed
18
+ 7. <code>create_resource_type</code> - removed
19
+ 8. <code>create_resource</code> - removed
20
+ 9. <code>create_resource_under_resource</code> - removed
21
+ 10. <code>create_metric_type</code> - removed
22
+ 11. <code>create_metric_for_resource</code> - removed
23
+ 12. <code>events</code> - removed
24
+ 13. <code>no_more_events!</code> - removed
25
+ 14. <code>list_metrics_for_resource_type
26
+ 15. <code>list_resource_types(feed_id)</code> - now the feed_id parameter is mandatory
27
+
28
+ Also the payload/parameters are now different:
29
+ * Metric ids follow this pattern <code>inventory.#{feedid}.#{type}.#{id}</code>
30
+ * Each metric is tagged with following tag <code>{module: 'inventory', feed: #{feedid}, type: #{type}, id: #{id}}</code>
31
+ * more details in the PR description (https://github.com/hawkular/hawkular-client-ruby/pull/196#issue-214961468)
32
+
6
33
  === V 2.9.0
7
34
  * Adding a way to update collection interval on the agent
8
35
  * Fixed <code>get_entity</code> method in the inventory client
data/README.rdoc CHANGED
@@ -6,12 +6,12 @@
6
6
 
7
7
  A Ruby Hawkular Client.
8
8
 
9
- Documentation[http://www.hawkular.org/hawkular-client-ruby/]
9
+ Documentation[http://www.hawkular.org/hawkular-client-ruby/docs/]
10
10
 
11
11
  == Changelog
12
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.
13
+ See {CHANGELOG}[http://www.hawkular.org/hawkular-client-ruby/docs/latest/file.CHANGES.html] for a list of changes and
14
+ {API-Breaking-Changes}[link:http://www.hawkular.org/hawkular-client-ruby/docs/latest/file.api_breaking_changes.html] for a list of api-breaking changes.
15
15
 
16
16
  == Overview
17
17
 
@@ -49,7 +49,7 @@ Metrics API is also subdivided to: Mixed, Availability, Counters, Gauges and Ten
49
49
  client.metrics.tenants # Tenants
50
50
 
51
51
  The Mixed API is capable of handling multiple types of metrics, like the
52
- push_data[Hawkular/Metrics/Client.html#push_data-instance_method] method, which pushes data
52
+ push_data[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Metrics/Client.html#push_data-instance_method] method, which pushes data
53
53
  for multiple metrics of all supported data.
54
54
 
55
55
  You can also access each subproject's API individually, if you would like to use only the metrics API you could do
@@ -102,20 +102,20 @@ Each network01_avail will be an array like:
102
102
  # ...
103
103
  ]
104
104
 
105
- You can get more info on the other parameters by checking the metrics API get_data[Hawkular/Metrics/Client/Metrics#get_data-instance_method]
105
+ You can get more info on the other parameters by checking the metrics API get_data[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Metrics/Client/Metrics#get_data-instance_method]
106
106
 
107
107
  === More info
108
108
 
109
109
  Check each resource API for a detailed description of what methods are available.
110
- * Alerts[Hawkular/Alerts/AlertsClient.html]
111
- * Inventory[Hawkular/Inventory/InventoryClient.html]
110
+ * Alerts[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Alerts/AlertsClient.html]
111
+ * Inventory[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Inventory/InventoryClient.html]
112
112
  * Metrics:
113
- * Mixed[Hawkular/Metrics/Client.html]
114
- * Availability[Hawkular/Metrics/Client/Availability.html]
115
- * Counters[Hawkular/Metrics/Client/Counters.html]
116
- * Gauges[Hawkular/Metrics/Client/Gauges.html]
117
- * Tenants[Hawkular/Metrics/Client/Tenants.html]
118
- * Operations[Hawkular/Operations/OperationsClient.html]
113
+ * Mixed[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Metrics/Client.html]
114
+ * Availability[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Metrics/Client/Availability.html]
115
+ * Counters[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Metrics/Client/Counters.html]
116
+ * Gauges[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Metrics/Client/Gauges.html]
117
+ * Tenants[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Metrics/Client/Tenants.html]
118
+ * Operations[http://www.hawkular.org/hawkular-client-ruby/docs/latest/Hawkular/Operations/OperationsClient.html]
119
119
 
120
120
  == Contributing to hawkular-client-ruby
121
121
 
@@ -145,7 +145,7 @@ Integration tests are recorded and played against cassettes recorded with VCR
145
145
  * Currently, we support two posible metrics contexts: <code>hawkular-metrics 0.8.0.Final</code> and <code>hawkular-services</code> that contain metrics. If you want to run/re-record the tests only for services, you can skip the other context by <code>SKIP_V8_METRICS=1</code>, or similarly <code>SKIP_SERVICES_METRICS=1</code>. So for instance updating the VCR templates only for hawkular-services would require command:
146
146
  VCR_UPDATE=1 SKIP_V8_METRICS=1 rspec ./spec/integration/metric_spec.rb
147
147
 
148
- For more details consult the {spec readme}[link:spec/README.rdoc].
148
+ For more details consult the {spec readme}[link:http://www.hawkular.org/hawkular-client-ruby/docs/latest/file.README.html].
149
149
 
150
150
  == Logging
151
151
 
@@ -246,8 +246,18 @@ module Hawkular::Alerts
246
246
  # @param [Hash]criteria optional query criteria
247
247
  # @return [Array<Alert>] List of alerts in the system. Can be empty
248
248
  def list_alerts(criteria = {})
249
+ alerts(criteria: criteria)
250
+ end
251
+
252
+ # List fired alerts
253
+ # @param [Hash] criteria optional query criteria
254
+ # @param [Array] tenants optional list of tenants. The elements of the array can be any object
255
+ # convertible to a string
256
+ # @return [Array<Alert>] List of alerts in the system. Can be empty
257
+ def alerts(criteria: {}, tenants:nil)
249
258
  query = generate_query_params(criteria)
250
- ret = http_get('/' + query)
259
+ uri = tenants ? '/admin/alerts/' : '/'
260
+ ret = http_get(uri + query, multi_tenants_header(tenants))
251
261
  val = []
252
262
  ret.each { |a| val.push(Alert.new(a)) }
253
263
  val
@@ -298,9 +308,26 @@ module Hawkular::Alerts
298
308
  # thin boolean, return lighter events (omits triggering data for trigger-generated events)
299
309
  # @param [Hash] criteria optional query criteria
300
310
  # @return [Array<Event>] List of events. Can be empty
301
- def list_events(*criteria)
302
- query = generate_query_params(*criteria)
303
- http_get('/events' + query).map { |e| Event.new(e) }
311
+ def list_events(criteria = {})
312
+ events(criteria: criteria)
313
+ end
314
+
315
+ # List Events given optional criteria. Criteria keys are strings (not symbols):
316
+ # startTime numeric, milliseconds from epoch
317
+ # endTime numeric, milliseconds from epoch
318
+ # eventIds array of strings
319
+ # triggerIds array of strings
320
+ # categories array of strings
321
+ # tags array of strings, each tag of format 'name|value'. Specify '*' for value to match all values
322
+ # thin boolean, return lighter events (omits triggering data for trigger-generated events)
323
+ # @param [Hash] criteria optional query criteria
324
+ # @param [Array] tenants optional list of tenants. The elements of the array can be any object
325
+ # convertible to a string
326
+ # @return [Array<Event>] List of events. Can be empty
327
+ def events(criteria: {}, tenants: nil)
328
+ query = generate_query_params(criteria)
329
+ uri = tenants ? '/admin/events' : '/events'
330
+ http_get(uri + query, multi_tenants_header(tenants)).map { |e| Event.new(e) }
304
331
  end
305
332
 
306
333
  # Inject an event into Hawkular-alerts
@@ -338,6 +365,18 @@ module Hawkular::Alerts
338
365
  query = generate_query_params(alertIds: alert_ids, tagNames: tag_names)
339
366
  http_delete('/tags' + query)
340
367
  end
368
+
369
+ private
370
+
371
+ # Builds the tenant HTTP header for multi-tenant operations
372
+ # @param [Array] tenants an array of tenant names. The elements of the array can
373
+ # be any object convertible to a string. Can be nil
374
+ # @return [Hash] The HTTP header for multi-tenant operations. An empty hash is returned
375
+ # if tenants parameter is nil
376
+ def multi_tenants_header(tenants)
377
+ tenants = tenants.join(',') if tenants.respond_to?(:join)
378
+ tenants ? { 'Hawkular-Tenant': tenants } : {}
379
+ end
341
380
  end
342
381
 
343
382
  # Representation of one Trigger
@@ -575,7 +614,4 @@ module Hawkular::Alerts
575
614
  super(event_hash)
576
615
  end
577
616
  end
578
-
579
- AlertsClient = Client
580
- deprecate_constant :AlertsClient if self.respond_to? :deprecate_constant
581
617
  end
@@ -37,6 +37,3 @@ module Hawkular
37
37
  end
38
38
  end
39
39
  end
40
-
41
- HawkularUtilsMixin = Hawkular::ClientUtils
42
- deprecate_constant(:HawkularUtilsMixin) if self.respond_to?(:deprecate_constant)
@@ -32,7 +32,7 @@ module Hawkular
32
32
  end
33
33
 
34
34
  def inventory
35
- @inventory ||= Inventory::Client.new("#{@state[:entrypoint]}/hawkular/inventory",
35
+ @inventory ||= Inventory::Client.new("#{@state[:entrypoint]}/hawkular/metrics",
36
36
  @state[:credentials],
37
37
  @state[:options])
38
38
  end
@@ -66,6 +66,8 @@ module Hawkular::Inventory
66
66
  super(res_hash)
67
67
  if res_hash.key? :resourceTypePath
68
68
  @type_path = res_hash[:resourceTypePath]
69
+ elsif res_hash.key? 'resourceTypePath'
70
+ @type_path = res_hash['resourceTypePath']
69
71
  else
70
72
  @type = res_hash['type']
71
73
  @type_path = res_hash['type']['path']
@@ -105,13 +107,13 @@ module Hawkular::Inventory
105
107
  # @return [String] metric id used in Hawkular Metrics
106
108
  attr_reader :hawkular_metric_id
107
109
 
108
- def initialize(metric_hash)
110
+ def initialize(metric_hash, metric_type)
109
111
  super(metric_hash)
110
- @type = metric_hash['type']['type']
111
- @type_path = metric_hash['type']['path']
112
- @type_id = metric_hash['type']['id']
113
- @unit = metric_hash['type']['unit']
114
- @collection_interval = metric_hash['type']['collectionInterval']
112
+ @type = metric_type.type
113
+ @type_path = metric_hash['metricTypePath']
114
+ @type_id = metric_type.id
115
+ @unit = metric_type.unit
116
+ @collection_interval = metric_hash['collectionInterval'] || metric_type.collection_interval
115
117
  @hawkular_metric_id = @properties.key?('hawkular-metric-id') ? @properties['hawkular-metric-id'] : @id
116
118
  end
117
119
  end
@@ -158,6 +160,8 @@ module Hawkular::Inventory
158
160
  end
159
161
 
160
162
  class CanonicalPath
163
+ include Hawkular::ClientUtils
164
+
161
165
  attr_reader :tenant_id
162
166
  attr_reader :feed_id
163
167
  attr_reader :environment_id
@@ -181,24 +185,47 @@ module Hawkular::Inventory
181
185
  CanonicalPath.new(path_to_h path)
182
186
  end
183
187
 
188
+ def self.parse_if_string(path)
189
+ path.is_a?(CanonicalPath) ? path : CanonicalPath.parse(path)
190
+ end
191
+
192
+ def copy_hash
193
+ hash = to_h
194
+ hash[:resource_ids] = hash[:resource_ids].clone unless hash[:resource_ids].nil?
195
+ hash
196
+ end
197
+
184
198
  # Move up to the parent path of the resource. resource_ids set to empty array when there is no parent.
185
199
  # @return CanonicalPath corresponding to the direct ancestor of the resource represented by this path object.
186
200
  def up
187
- hash = to_h
188
- if hash[:resource_ids].nil?
189
- hash[:resource_ids] = []
190
- else
191
- hash[:resource_ids].pop
192
- end
201
+ hash = copy_hash
202
+ res = hash[:resource_ids] || []
203
+ res = res.take(res.length - 1) unless res.empty?
204
+ hash[:resource_ids] = res
193
205
  CanonicalPath.new(hash)
194
206
  end
195
207
 
196
- # Adds a resource to the path.
197
- # @return CanonicalPath referring to resource_id using current as its ancestor.
198
- def to_resource(resource_id)
199
- hash = to_h
200
- hash[:resource_ids] = [] if hash[:resource_ids].nil?
201
- hash[:resource_ids].push resource_id
208
+ # Add resource down to the current path
209
+ # @return a new CanonicalPath based on the current one
210
+ def down(resource)
211
+ hash = copy_hash
212
+ hash[:resource_ids] = (hash[:resource_ids] || []) << hawk_escape_id(resource)
213
+ CanonicalPath.new(hash)
214
+ end
215
+
216
+ # Set resource type to the current path
217
+ # @return a new CanonicalPath based on the current one
218
+ def resource_type(resource_type)
219
+ hash = copy_hash
220
+ hash[:resource_type_id] = hawk_escape_id(resource_type)
221
+ CanonicalPath.new(hash)
222
+ end
223
+
224
+ # Set metric type to the current path
225
+ # @return a new CanonicalPath based on the current one
226
+ def metric_type(metric_type)
227
+ hash = copy_hash
228
+ hash[:metric_type_id] = hawk_escape_id(metric_type)
202
229
  CanonicalPath.new(hash)
203
230
  end
204
231
 
@@ -224,11 +251,20 @@ module Hawkular::Inventory
224
251
  ret += "/e;#{@environment_id}" unless @environment_id.nil?
225
252
  ret += "/rt;#{@resource_type_id}" unless @resource_type_id.nil?
226
253
  ret += "/mt;#{@metric_type_id}" unless @metric_type_id.nil?
227
- ret += "/m;#{@metric_id}" unless @metric_id.nil?
228
254
  ret += resources_chunk.to_s
255
+ ret += "/m;#{@metric_id}" unless @metric_id.nil?
229
256
  ret
230
257
  end
231
258
 
259
+ def to_tags
260
+ fail 'Missing feed_id' if @feed_id.nil?
261
+ tags = "module:inventory,feed:#{Regexp.quote(@feed_id)}"
262
+ tags += ",type:rt,id:#{Regexp.quote(@resource_type_id)}" if @resource_type_id
263
+ tags += ",type:mt,id:#{Regexp.quote(@metric_type_id)}" if @metric_type_id
264
+ tags += ",type:r,id:#{Regexp.quote(@resource_ids[0])}" if @resource_ids && (!@resource_ids.empty?)
265
+ tags
266
+ end
267
+
232
268
  protected
233
269
 
234
270
  def state
@@ -1,6 +1,8 @@
1
1
  require 'hawkular/base_client'
2
2
  require 'websocket-client-simple'
3
3
  require 'json'
4
+ require 'zlib'
5
+ require 'stringio'
4
6
 
5
7
  require 'hawkular/inventory/entities'
6
8
 
@@ -20,7 +22,7 @@ module Hawkular::Inventory
20
22
  # @param credentials [Hash{String=>String}] Hash of username, password, token(optional)
21
23
  # @param options [Hash{String=>String}] Additional rest client options
22
24
  def initialize(entrypoint = nil, credentials = {}, options = {})
23
- entrypoint = normalize_entrypoint_url entrypoint, 'hawkular/inventory'
25
+ entrypoint = normalize_entrypoint_url entrypoint, 'hawkular/metrics'
24
26
  @entrypoint = entrypoint
25
27
  super(entrypoint, credentials, options)
26
28
  version = fetch_version_and_status['Implementation-Version']
@@ -32,45 +34,54 @@ module Hawkular::Inventory
32
34
  # entrypoint: http://localhost:8080/hawkular/inventory
33
35
  # and another sub-hash containing the hash with username[String], password[String], token(optional)
34
36
  def self.create(hash)
35
- fail 'no parameter ":entrypoint" given' if hash[:entrypoint].nil?
37
+ fail 'no parameter ":entrypoint" given' unless hash[:entrypoint]
36
38
  hash[:credentials] ||= {}
37
39
  hash[:options] ||= {}
38
40
  Client.new(hash[:entrypoint], hash[:credentials], hash[:options])
39
41
  end
40
42
 
41
- # Retrieve the tenant id for the passed credentials.
42
- # If no credentials are passed, the ones from the constructor are used
43
- # @param credentials [Hash{String=>String}] Hash of username, password, token(optional)
44
- # @return [String] tenant id
45
- # @deprecated this doesn't provide any value, because it merely returns the tenant ID which is known before the
46
- # call anyway.
47
- def get_tenant(credentials = {})
48
- creds = credentials.empty? ? @credentials : credentials
49
- auth_header = { Authorization: base_64_credentials(creds) }
50
-
51
- ret = http_get('/tenant', auth_header)
52
-
53
- ret['id']
54
- end
55
-
56
43
  # List feeds in the system
57
44
  # @return [Array<String>] List of feed ids
58
45
  def list_feeds
59
- ret = http_get('/traversal/type=f')
60
- ret.map { |f| f['id'] }
46
+ ret = http_get('/strings/tags/module:inventory,feed:*')
47
+ return [] unless ret.key? 'feed'
48
+ ret['feed']
61
49
  end
62
50
 
63
- # List resource types. If no feed_id is given all types are listed
64
- # @param [String] feed_id The id of the feed the type lives under. Can be nil for feedless types
51
+ # List resource types for the given feed
52
+ # @param [String] feed_id The id of the feed the type lives under
65
53
  # @return [Array<ResourceType>] List of types, that can be empty
66
- def list_resource_types(feed_id = nil)
67
- if feed_id.nil?
68
- ret = http_get('/traversal/type=rt')
69
- else
70
- the_feed = hawk_escape_id feed_id
71
- ret = http_get("/traversal/f;#{the_feed}/type=rt")
54
+ def list_resource_types(feed_id)
55
+ fail 'Feed id must be given' unless feed_id
56
+ feed_path = feed_cp(feed_id)
57
+ response = http_post(
58
+ '/strings/raw/query',
59
+ fromEarliest: true,
60
+ order: 'DESC',
61
+ tags: "#{feed_path.to_tags},type:rt")
62
+ structures = extract_structures_from_body(response)
63
+ structures.map do |rt|
64
+ root_hash = entity_json_to_hash(-> (id) { feed_path.resource_type(id) }, rt['inventoryStructure'], false)
65
+ ResourceType.new(root_hash)
66
+ end
67
+ end
68
+
69
+ # List metric types for the given feed
70
+ # @param [String] feed_id The id of the feed the type lives under
71
+ # @return [Array<MetricType>] List of types, that can be empty
72
+ def list_metric_types(feed_id)
73
+ fail 'Feed id must be given' unless feed_id
74
+ feed_path = feed_cp(feed_id)
75
+ response = http_post(
76
+ '/strings/raw/query',
77
+ fromEarliest: true,
78
+ order: 'DESC',
79
+ tags: "#{feed_path.to_tags},type:mt")
80
+ structures = extract_structures_from_body(response)
81
+ structures.map do |mt|
82
+ root_hash = entity_json_to_hash(-> (id) { feed_path.metric_type(id) }, mt['inventoryStructure'], false)
83
+ MetricType.new(root_hash)
72
84
  end
73
- ret.map { |rt| ResourceType.new(rt) }
74
85
  end
75
86
 
76
87
  # Return all resources for a feed
@@ -79,14 +90,16 @@ module Hawkular::Inventory
79
90
  # @return [Array<Resource>] List of resources, which can be empty.
80
91
  def list_resources_for_feed(feed_id, fetch_properties = false, filter = {})
81
92
  fail 'Feed id must be given' unless feed_id
82
- the_feed = hawk_escape_id feed_id
83
- ret = http_get("/traversal/f;#{the_feed}/type=r")
84
- to_filter = ret.map do |r|
85
- if fetch_properties
86
- p = get_config_data_for_resource(r['path'])
87
- r['properties'] = p['value']
88
- end
89
- Resource.new(r)
93
+ feed_path = feed_cp(feed_id)
94
+ response = http_post(
95
+ '/strings/raw/query',
96
+ fromEarliest: true,
97
+ order: 'DESC',
98
+ tags: "#{feed_path.to_tags},type:r")
99
+ structures = extract_structures_from_body(response)
100
+ to_filter = structures.map do |r|
101
+ root_hash = entity_json_to_hash(-> (id) { feed_path.down(id) }, r['inventoryStructure'], fetch_properties)
102
+ Resource.new(root_hash)
90
103
  end
91
104
  filter_entities(to_filter, filter)
92
105
  end
@@ -99,33 +112,34 @@ module Hawkular::Inventory
99
112
  # @param [Boolean] fetch_properties Shall additional runtime properties be fetched?
100
113
  # @return [Array<Resource>] List of resources. Can be empty
101
114
  def list_resources_for_type(resource_type_path, fetch_properties = false)
102
- path = resource_type_path.is_a?(CanonicalPath) ? resource_type_path : CanonicalPath.parse(resource_type_path)
103
- resource_type_id = path.resource_type_id
104
- feed_id = path.feed_id
105
- if feed_id.nil?
106
- ret = http_get("/traversal/rt;#{resource_type_id}/rl;defines/type=r")
107
- else
108
- ret = http_get("/traversal/f;#{feed_id}/rt;#{resource_type_id}/rl;defines/type=r")
109
- end
110
- ret.map do |r|
111
- if fetch_properties && !feed_id.nil?
112
- p = get_config_data_for_resource(r['path'])
113
- r['properties'] = p['value']
114
- end
115
- Resource.new(r)
116
- end
115
+ path = CanonicalPath.parse_if_string(resource_type_path)
116
+ fail 'Feed id must be given' unless path.feed_id
117
+ fail 'Resource type must be given' unless path.resource_type_id
118
+
119
+ # Fetch metrics by tag
120
+ feed_path = feed_cp(URI.unescape(path.feed_id))
121
+ resource_type_id = URI.unescape(path.resource_type_id)
122
+ escaped_for_regex = Regexp.quote("|#{resource_type_id}|")
123
+ response = http_post(
124
+ '/strings/raw/query',
125
+ fromEarliest: true,
126
+ order: 'DESC',
127
+ tags: "#{feed_path.to_tags},type:r,restypes:.*#{escaped_for_regex}.*")
128
+ structures = extract_structures_from_body(response)
129
+ return [] if structures.empty?
130
+
131
+ # Now find each collected resource path in their belonging InventoryStructure
132
+ extract_resources_for_type(structures, feed_path, resource_type_id, fetch_properties)
117
133
  end
118
134
 
119
135
  # Retrieve runtime properties for the passed resource
120
136
  # @param [String] resource_path Canonical path of the resource to read properties from.
121
137
  # @return [Hash<String,Object] Hash with additional data
122
138
  def get_config_data_for_resource(resource_path)
123
- path = resource_path.is_a?(CanonicalPath) ? resource_path : CanonicalPath.parse(resource_path)
124
- resource_path = 'r;' + path.resource_ids.join('/r;')
125
- feed_id = path.feed_id
126
- http_get("/entity/f;#{feed_id}/#{resource_path}/d;configuration")
127
- rescue
128
- {}
139
+ path = CanonicalPath.parse_if_string(resource_path)
140
+ raw_hash = get_raw_entity_hash(path)
141
+ return {} unless raw_hash
142
+ { 'value' => fetch_properties(raw_hash) }
129
143
  end
130
144
 
131
145
  # Obtain the child resources of the passed resource. In case of a WildFly server,
@@ -135,108 +149,38 @@ module Hawkular::Inventory
135
149
  # @return [Array<Resource>] List of resources that are children of the given parent resource.
136
150
  # Can be empty
137
151
  def list_child_resources(parent_res_path, recursive = false)
138
- path = parent_res_path.is_a?(CanonicalPath) ? parent_res_path : CanonicalPath.parse(parent_res_path)
139
- parent_resource_path = 'r;' + path.resource_ids.join('/r;')
152
+ path = CanonicalPath.parse_if_string(parent_res_path)
140
153
  feed_id = path.feed_id
141
-
142
- if recursive
143
- ret = http_get("/traversal/f;#{feed_id}/#{parent_resource_path}/recursive;over=isParentOf;type=r")
144
- else
145
- ret = http_get("/traversal/f;#{feed_id}/#{parent_resource_path}/type=r")
146
- end
147
- ret.map { |r| Resource.new(r) }
148
- end
149
-
150
- # Obtain a list of relationships starting at the passed resource
151
- # @param [String] entity_path Canonical path of the entity that forms the one end of the relationship
152
- # @param [String] named Name of the relationship
153
- # @return [Array<Relationship>] List of relationships
154
- def list_relationships(entity_path, named = nil)
155
- path = entity_path.is_a?(CanonicalPath) ? entity_path : CanonicalPath.parse(entity_path)
156
- query_params = {
157
- sort: '__targetCp'
158
- }
159
-
160
- query = generate_query_params query_params
161
- if named.nil?
162
- ret = http_get("/traversal#{path}/relationships#{query}")
163
- else
164
- ret = http_get("/traversal#{path}/relationships;name=#{named}#{query}")
165
- end
166
-
167
- ret.map { |r| Relationship.new(r) }
168
- end
169
-
170
- # Obtain a list of relationships for the passed feed
171
- # @param [String] feed_id Id of the feed
172
- # @param [String] named Name of the relationship
173
- # @return [Array<Relationship>] List of relationships
174
- def list_relationships_for_feed(feed_id, named = nil)
175
- the_feed = hawk_escape_id feed_id
176
- query_params = {
177
- sort: '__targetCp'
178
- }
179
-
180
- query = generate_query_params query_params
181
- if named.nil?
182
- ret = http_get("/traversal/f;#{the_feed}/relationships#{query}")
183
- else
184
- ret = http_get("/traversal;/f;#{the_feed}/relationships;named=#{named}#{query}")
185
- end
186
-
187
- ret.map { |r| Relationship.new(r) }
188
- rescue
189
- []
190
- end
191
-
192
- # Retrieve a single entity from inventory by its canonical path
193
- # @param [String] path canonical path of the entity
194
- # @return inventory entity
195
- def get_entity(path)
196
- c_path = path.is_a?(CanonicalPath) ? path : CanonicalPath.parse(path)
197
- http_get("/entity#{c_path}")
154
+ fail 'Feed id must be given' unless feed_id
155
+ entity_hash = get_raw_entity_hash(path)
156
+ extract_child_resources([], path.to_s, entity_hash, recursive) if entity_hash
198
157
  end
199
158
 
200
159
  # List the metrics for the passed metric type. If feed is not passed in the path,
201
160
  # all the metrics across all the feeds of a given type will be retrieved
202
- # This method may perform multiple REST calls.
203
161
  # @param [String] metric_type_path Canonical path of the resource type to look for. Can be obtained from
204
162
  # {MetricType}.path. Must not be nil. The tenant_id in the canonical path doesn't have to be there.
205
163
  # @return [Array<Metric>] List of metrics. Can be empty
206
164
  def list_metrics_for_metric_type(metric_type_path)
207
- path = metric_type_path.is_a?(CanonicalPath) ? metric_type_path : CanonicalPath.parse(metric_type_path)
208
- metric_type_id = path.metric_type_id
209
- feed_id = path.feed_id
210
- if feed_id.nil?
211
- ret = http_get("/traversal/mt;#{metric_type_id}/rl;defines/type=m")
212
- else
213
- ret = http_get("/traversal/f;#{feed_id}/mt;#{metric_type_id}/rl;defines/type=m")
214
- end
215
-
216
- ret.map { |m| Metric.new(m) }
217
- rescue
218
- []
219
- end
220
-
221
- # List the metrics for all the resources of a given resource type.
222
- # If feed is not passed in the resource type canonical path, all the metrics across all the feeds of a resource
223
- # type will be retrieved. This method may perform multiple REST calls.
224
- # @param [String] resource_type_path Canonical path of the resource type to look for. Can be obtained from
225
- # {ResourceType}.path. Must not be nil. The tenant_id in the canonical path doesn't have to be there.
226
- # @return [Array<Metric>] List of metrics. Can be empty
227
- def list_metrics_for_resource_type(resource_type_path)
228
- path = resource_type_path.is_a?(CanonicalPath) ? resource_type_path : CanonicalPath.parse(resource_type_path)
229
- resource_type_id = path.resource_type_id
230
- feed_id = path.feed_id
231
-
232
- query = generate_query_params sort: 'id'
233
- if feed_id.nil?
234
- ret = http_get("/traversal/rt;#{resource_type_id}/rl;defines/type=r/rl;incorporates/type=m#{query}")
235
- else
236
- ret = http_get(
237
- "/traversal/f;#{feed_id}/rt;#{resource_type_id}/rl;defines/type=r/rl;incorporates/type=m#{query}")
238
- end
239
- ret.map { |m| Metric.new(m) }
165
+ path = CanonicalPath.parse_if_string(metric_type_path)
166
+ fail 'Feed id must be given' unless path.feed_id
167
+ fail 'Metric type id must be given' unless path.metric_type_id
168
+ feed_id = URI.unescape(path.feed_id)
169
+ metric_type_id = URI.unescape(path.metric_type_id)
170
+
171
+ feed_path = feed_cp(feed_id)
172
+ escaped_for_regex = Regexp.quote("|#{metric_type_id}|")
173
+ response = http_post(
174
+ '/strings/raw/query',
175
+ fromEarliest: true,
176
+ order: 'DESC',
177
+ tags: "#{feed_path.to_tags},type:r,mtypes:.*#{escaped_for_regex}.*")
178
+ structures = extract_structures_from_body(response)
179
+ return [] if structures.empty?
180
+
181
+ # Now find each collected resource path in their belonging InventoryStructure
182
+ metric_type = get_metric_type(path)
183
+ extract_metrics_for_type(structures, feed_path, metric_type)
240
184
  end
241
185
 
242
186
  # List metric (definitions) for the passed resource. It is possible to filter down the
@@ -254,179 +198,87 @@ module Hawkular::Inventory
254
198
  # # Don't filter, return all metric definitions
255
199
  # client.list_metrics_for_resource(wild_fly)
256
200
  def list_metrics_for_resource(resource_path, filter = {})
257
- path = resource_path.is_a?(CanonicalPath) ? resource_path : CanonicalPath.parse(resource_path)
258
- feed_id = path.feed_id
259
- resource_path_escaped = 'r;' + path.resource_ids.join('/r;')
260
-
261
- query = generate_query_params sort: 'id'
262
- ret = http_get("/traversal/f;#{feed_id}/#{resource_path_escaped}/rl;incorporates/type=m#{query}")
263
- to_filter = ret.map { |m| Metric.new(m) }
264
- filter_entities(to_filter, filter)
265
- end
266
-
267
- # Create a new feed
268
- # @param [String] feed_id Id of a feed - required
269
- # @param [String] feed_name A display name for the feed
270
- # @return [Object]
271
- def create_feed(feed_id, feed_name = nil)
272
- feed = create_blueprint
273
- feed[:id] = feed_id
274
- feed[:name] = feed_name
275
-
276
- begin
277
- return http_post('/entity/feed', feed)
278
- rescue HawkularException => error
279
- # 409 We already exist -> that is ok
280
- if error.status_code == 409
281
- the_feed = hawk_escape_id feed_id
282
- http_get("/entity/f;#{the_feed}")
283
- else
284
- raise
285
- end
286
- end
287
- end
288
-
289
- # Delete the feed with the passed feed id.
290
- # @param feed_id Id of the feed to be deleted.
291
- def delete_feed(feed_id)
292
- the_feed = hawk_escape_id feed_id
293
- http_delete("/entity/f;#{the_feed}")
294
- end
295
-
296
- # Create a new resource type
297
- # @param [String] feed_id Id of the feed to add the type to
298
- # @param [String] type_id Id of the new type
299
- # @param [String] type_name Name of the type
300
- # @return [ResourceType] ResourceType object just created
301
- def create_resource_type(feed_id, type_id, type_name)
302
- the_feed = hawk_escape_id feed_id
303
-
304
- type = create_blueprint
305
- type[:id] = type_id
306
- type[:name] = type_name
307
-
308
- begin
309
- http_post("/entity/f;#{the_feed}/resourceType", type)
310
- rescue HawkularException => error
311
- # 409 We already exist -> that is ok
312
- raise unless error.status_code == 409
313
- ensure
314
- the_type = hawk_escape_id type_id
315
- res = http_get("/entity/f;#{the_feed}/rt;#{the_type}")
316
- end
317
- ResourceType.new(res)
318
- end
319
-
320
- # Create a resource of a given type. To retrieve that resource
321
- # you need to call {#get_resource}
322
- # @param [String] resource_type_path Canonical path of the new resource's type.
323
- # @param [String] resource_id Id of the new resource
324
- # @param [String] resource_name Name of the new resource
325
- # @param [Hash<String,Object>] properties Additional properties. Those are not the config-properties
326
- def create_resource(resource_type_path, resource_id, resource_name = nil, properties = {})
327
- create_resource_under_resource(resource_type_path, nil, resource_id, resource_name, properties)
328
- end
329
-
330
- # Create a resource of a given type under a given resource. To retrieve that resource
331
- # you need to call {#get_resource}
332
- # @param [String] res_type_path Canonical path of the new resource's type.
333
- # @param [String] parent_res_path Canonical path of the resource under which we create this resource.
334
- # If nil, the top-lvl resource will be created.
335
- # @param [String] resource_id Id of the resource
336
- # @param [String] resource_name Name of the resource
337
- # @param [Hash<String,Object>] properties Additional properties. Those are not the config-properties
338
- def create_resource_under_resource(res_type_path, parent_res_path, resource_id, resource_name = nil,
339
- properties = {})
340
- type_path = res_type_path.is_a?(CanonicalPath) ? res_type_path : CanonicalPath.parse(res_type_path)
341
- feed_id = type_path.feed_id
342
-
343
- res = create_blueprint
344
- res[:properties] = properties
345
- res[:id] = resource_id
346
- res[:name] = resource_name
347
- res[:resourceTypePath] = type_path.to_s
348
-
349
- begin
350
- if parent_res_path.nil?
351
- res = http_post("/entity/f;#{feed_id}/resource", res)
352
- else
353
- path = parent_res_path.is_a?(CanonicalPath) ? parent_res_path : CanonicalPath.parse(parent_res_path)
354
- resource_path = 'r;' + path.resource_ids.join('/r;')
355
- res = http_post("/entity/f;#{feed_id}/#{resource_path}/resource", res)
356
- end
357
- rescue HawkularException => error
358
- # 409 We already exist -> that is ok
359
- raise unless error.status_code == 409
360
- # Ensure we have a consistent behaviour if resource already exists Issue#180
361
- if parent_res_path.nil?
362
- hash = type_path.to_h
363
- hash.delete(:metric_type_id)
364
- path = CanonicalPath.new(hash)
201
+ path = CanonicalPath.parse_if_string(resource_path)
202
+ raw_hash = get_raw_entity_hash(path)
203
+ return [] unless raw_hash
204
+ to_filter = []
205
+ if (raw_hash.key? 'children') && (raw_hash['children'].key? 'metric') && !raw_hash['children']['metric'].empty?
206
+ # Need to merge metric type info that we must grab from another place
207
+ metric_types = list_metric_types(path.feed_id)
208
+ metric_types_index = {}
209
+ metric_types.each { |mt| metric_types_index[mt.path] = mt }
210
+ to_filter = raw_hash['children']['metric'].map do |m|
211
+ metric_data = m['data']
212
+ metric_data['path'] = "#{path}/m;#{metric_data['id']}"
213
+ metric_type = metric_types_index[metric_data['metricTypePath']]
214
+ Metric.new(metric_data, metric_type) if metric_type
365
215
  end
366
- res = get_resource(path.to_resource(resource_id)).to_h
216
+ to_filter = to_filter.select { |m| m }
367
217
  end
368
- Resource.new(res)
218
+ filter_entities(to_filter, filter)
369
219
  end
370
220
 
371
221
  # Return the resource object for the passed path
372
222
  # @param [String] resource_path Canonical path of the resource to fetch.
373
- # @param [Boolean] fetch_resource_config Should the resource config data be fetched?
374
- def get_resource(resource_path, fetch_resource_config = true)
375
- path = resource_path.is_a?(CanonicalPath) ? resource_path : CanonicalPath.parse(resource_path)
376
- feed_id = path.feed_id
377
- res_path = 'r;' + path.resource_ids.join('/r;')
378
-
379
- res = http_get("/entity/f;#{feed_id}/#{res_path}")
380
- if fetch_resource_config
381
- p = get_config_data_for_resource(resource_path)
382
- res['properties'] ||= {}
383
- res['properties'].merge! p['value'] unless p['value'].nil?
223
+ # @param [Boolean] fetch_properties Should the resource config data be fetched?
224
+ def get_resource(resource_path, fetch_properties = true)
225
+ path = CanonicalPath.parse_if_string(resource_path)
226
+ raw_hash = get_raw_entity_hash(path)
227
+ unless raw_hash
228
+ exception = HawkularException.new("Resource not found: #{resource_path}")
229
+ fail exception
384
230
  end
385
- Resource.new(res)
231
+ entity_hash = entity_json_to_hash(-> (_) { path }, raw_hash, fetch_properties)
232
+ Resource.new(entity_hash)
386
233
  end
387
234
 
388
- # Create a new metric type for a feed
389
- # @param [String] feed_id Id of the feed
390
- # @param [String] metric_type_id Id of the metric type to create
391
- # @param [String] type Type of the Metric. Allowed are GAUGE,COUNTER, AVAILABILITY
392
- # @param [String] unit Unit of the metric
393
- # @param [Numeric] collection_interval
394
- # @return [MetricType] Type just created or the one from the server if it already existed.
395
- def create_metric_type(feed_id, metric_type_id, type = 'GAUGE', unit = 'NONE', collection_interval = 60)
396
- the_feed = hawk_escape_id feed_id
397
-
398
- metric_kind = type.nil? ? 'GAUGE' : type.upcase
399
- fail "Unknown type #{metric_kind}" unless %w(GAUGE COUNTER AVAILABILITY').include?(metric_kind)
400
-
401
- mt = build_metric_type_hash(collection_interval, metric_kind, metric_type_id, unit)
402
-
403
- begin
404
- http_post("/entity/f;#{the_feed}/metricType", mt)
405
- rescue HawkularException => error
406
- # 409 We already exist -> that is ok
407
- raise unless error.status_code == 409
235
+ # Return the resource type object for the passed path
236
+ # @param [String] resource_type_path Canonical path of the resource type to fetch.
237
+ def get_resource_type(resource_type_path)
238
+ path = CanonicalPath.parse_if_string(resource_type_path)
239
+ raw_hash = get_raw_entity_hash(path)
240
+ unless raw_hash
241
+ exception = HawkularException.new("Resource type not found: #{resource_type_path}")
242
+ fail exception
408
243
  end
244
+ entity_hash = entity_json_to_hash(-> (_) { path }, raw_hash, false)
245
+ ResourceType.new(entity_hash)
246
+ end
409
247
 
410
- new_mt = http_get("/entity/f;#{the_feed}/mt;#{metric_type_id}")
411
-
412
- MetricType.new(new_mt)
248
+ # Return the metric type object for the passed path
249
+ # @param [String] metric_type_path Canonical path of the metric type to fetch.
250
+ def get_metric_type(metric_type_path)
251
+ path = CanonicalPath.parse_if_string(metric_type_path)
252
+ raw_hash = get_raw_entity_hash(path)
253
+ unless raw_hash
254
+ exception = HawkularException.new("Metric type not found: #{metric_type_path}")
255
+ fail exception
256
+ end
257
+ entity_hash = entity_json_to_hash(-> (_) { path }, raw_hash, false)
258
+ MetricType.new(entity_hash)
413
259
  end
414
260
 
415
261
  # List operation definitions (types) for a given resource type
416
262
  # @param [String] resource_type_path canonical path of the resource type entity
417
263
  # @return [Array<String>] List of operation type ids
418
264
  def list_operation_definitions(resource_type_path)
419
- parsed_path = CanonicalPath.parse(resource_type_path.to_s)
420
- feed_id = parsed_path.feed_id
421
- resource_type_id = parsed_path.resource_type_id
422
- ots = http_get("/traversal/f;#{feed_id}/rt;#{resource_type_id}/type=ot")
265
+ path = CanonicalPath.parse_if_string(resource_type_path)
266
+ fail 'Missing feed_id in resource_type_path' unless path.feed_id
267
+ fail 'Missing resource_type_id in resource_type_path' unless path.resource_type_id
268
+ response = http_post(
269
+ '/strings/raw/query',
270
+ fromEarliest: true,
271
+ order: 'DESC',
272
+ tags: path.to_tags)
273
+ structures = extract_structures_from_body(response)
423
274
  res = {}
424
- ots.each do |ot|
425
- ot_name = ERB::Util.url_encode ot['name']
426
- pts = http_get("/traversal/f;#{feed_id}/rt;#{resource_type_id}/ot;#{ot_name}/d;parameterTypes")
427
- ot['parameters'] = pts[0]['value'] unless pts.empty?
428
- od = OperationDefinition.new ot
429
- res.store od.name, od
275
+ structures.map { |rt| rt['inventoryStructure'] }
276
+ .select { |rt| rt['children'] && rt['children']['operationType'] }
277
+ .flat_map { |rt| rt['children']['operationType'] }
278
+ .each do |ot|
279
+ hash = optype_json_to_hash(ot)
280
+ od = OperationDefinition.new hash
281
+ res[od.name] = od
430
282
  end
431
283
  res
432
284
  end
@@ -435,94 +287,10 @@ module Hawkular::Inventory
435
287
  # @param [String] resource_path canonical path of the resource entity
436
288
  # @return [Array<String>] List of operation type ids
437
289
  def list_operation_definitions_for_resource(resource_path)
438
- resource = get_resource(resource_path.to_s, false)
290
+ resource = get_resource(resource_path, false)
439
291
  list_operation_definitions(resource.type_path)
440
292
  end
441
293
 
442
- # Create a Metric and associate it with a resource.
443
- # @param [String] metric_type_path Canonical path of the metric type of the new metric.
444
- # @param [String] resource_path Canonical path of the resource to which we want to associate the metric.
445
- # @param [String] metric_id Id of the metric
446
- # @param [String] metric_name a (display) name for the metric. If nil, #metric_id is used.
447
- # @return [Metric] The metric created or if it already existed the version from the server
448
- def create_metric_for_resource(metric_type_path, resource_path, metric_id, metric_name = nil)
449
- type_path = metric_type_path.is_a?(CanonicalPath) ? metric_type_path : CanonicalPath.parse(metric_type_path)
450
- feed_id = type_path.feed_id
451
- res_path = resource_path.is_a?(CanonicalPath) ? resource_path : CanonicalPath.parse(resource_path)
452
- res_path_str = 'r;' + res_path.resource_ids.join('/r;')
453
-
454
- m = {}
455
- m['id'] = metric_id
456
- m['name'] = metric_name || metric_id
457
- m['metricTypePath'] = type_path.to_s
458
-
459
- begin
460
- http_post("/entity/f;#{feed_id}/metric", m)
461
- rescue HawkularException => error
462
- # 409 We already exist -> that is ok
463
- raise unless error.status_code == 409
464
- end
465
-
466
- ret = http_get("/entity/f;#{feed_id}/m;#{metric_id}")
467
- the_metric = Metric.new(ret)
468
-
469
- begin
470
- rl = {}
471
- rl['otherEnd'] = the_metric.path.to_s
472
- rl['name'] = 'incorporates'
473
- http_post("/entity/f;#{feed_id}/#{res_path_str}/relationship", [rl])
474
- rescue HawkularException => error
475
- # 409 We already exist -> that is ok
476
- raise unless error.status_code == 409
477
- end
478
- the_metric
479
- end
480
-
481
- # Listen on inventory changes
482
- # @param [String] type Type of entity for which we want the events.
483
- # Allowed values: resource, metric, resourcetype, metrictype, feed, environment, operationtype, metadatapack
484
- # @param [String] action What types of events are we interested in.
485
- # Allowed values: created, updated, deleted, copied, registered
486
- def events(type = 'resource', action = 'created')
487
- tenant_id = get_tenant
488
-
489
- base64_creds = ["#{@credentials[:username]}:#{@credentials[:password]}"].pack('m').delete("\r\n")
490
- ws_options = {
491
- headers: {
492
- Authorization: 'Basic ' + base64_creds,
493
- Accept: 'application/json'
494
- }
495
- }
496
- ws_options[:headers][:'Hawkular-Tenant'] = tenant_id
497
-
498
- url = normalize_entrypoint_url(@entrypoint, "ws/events?tenantId=#{tenant_id}&type=#{type}&action=#{action}")
499
- url = url_with_websocket_scheme(url)
500
- @ws = WebSocket::Client::Simple.connect url, ws_options do |client|
501
- client.on :message do |msg|
502
- parsed_message = JSON.parse(msg.data)
503
- entity = case type
504
- when 'resource'
505
- Resource.new(parsed_message)
506
- when 'resourcetype'
507
- ResourceType.new(parsed_message)
508
- when 'metric'
509
- Metric.new(parsed_message)
510
- when 'metrictype'
511
- MetricType.new(parsed_message)
512
- else
513
- BaseEntity.new(parsed_message)
514
- end
515
- yield entity
516
- end
517
- end
518
- end
519
-
520
- # Stop listening on inventory events.
521
- # this method closes the web socket connection
522
- def no_more_events!
523
- @ws.close
524
- end
525
-
526
294
  # Return version and status information for the used version of Hawkular-Inventory
527
295
  # @return [Hash{String=>String}]
528
296
  # ('Implementation-Version', 'Built-From-Git-SHA1', 'Status')
@@ -530,27 +298,11 @@ module Hawkular::Inventory
530
298
  http_get('/status')
531
299
  end
532
300
 
533
- private
534
-
535
- # Creates a hash with the fields required by the Blueprint api in Hawkular-Inventory
536
- def create_blueprint
537
- res = {}
538
- res[:properties] = {}
539
- res[:id] = nil
540
- res[:name] = nil
541
- res[:outgoing] = {}
542
- res[:incoming] = {}
543
- res
301
+ def feed_cp(feed_id)
302
+ CanonicalPath.new(tenant_id: @tenant, feed_id: hawk_escape_id(feed_id))
544
303
  end
545
304
 
546
- def build_metric_type_hash(collection_interval, metric_kind, metric_type_id, unit)
547
- mt = {}
548
- mt['id'] = metric_type_id
549
- mt['type'] = metric_kind
550
- mt['unit'] = unit.nil? ? 'NONE' : unit.upcase
551
- mt['collectionInterval'] = collection_interval.nil? ? 60 : collection_interval
552
- mt
553
- end
305
+ private
554
306
 
555
307
  def filter_entities(entities, filter)
556
308
  entities.select do |entity|
@@ -564,8 +316,157 @@ module Hawkular::Inventory
564
316
  found
565
317
  end
566
318
  end
567
- end
568
319
 
569
- InventoryClient = Client
570
- deprecate_constant :InventoryClient if self.respond_to? :deprecate_constant
320
+ def entity_json_to_hash(path_getter, json, fetch_properties)
321
+ data = json['data']
322
+ data['path'] = path_getter.call(data['id']).to_s
323
+ if fetch_properties
324
+ props = fetch_properties(json)
325
+ data['properties'].merge! props if props
326
+ end
327
+ data
328
+ end
329
+
330
+ def fetch_properties(json)
331
+ return unless (json.key? 'children') && (json['children'].key? 'dataEntity')
332
+ config = json['children']['dataEntity'].find { |d| d['data']['id'] == 'configuration' }
333
+ config['data']['value'] if config
334
+ end
335
+
336
+ def optype_json_to_hash(json)
337
+ data = json['data']
338
+ # Fetch parameterTypes
339
+ if (json.key? 'children') && (json['children'].key? 'dataEntity')
340
+ param_types = json['children']['dataEntity'].find { |d| d['data']['id'] == 'parameterTypes' }
341
+ data['parameters'] = param_types['data']['value'] if param_types
342
+ end
343
+ data
344
+ end
345
+
346
+ def get_raw_entity_hash(path)
347
+ c_path = CanonicalPath.parse_if_string(path)
348
+ raw = http_post(
349
+ '/strings/raw/query',
350
+ fromEarliest: true,
351
+ order: 'DESC',
352
+ tags: c_path.to_tags
353
+ )
354
+ structure = extract_structure_from_body(raw)
355
+ find_entity_in_tree(c_path, structure)
356
+ end
357
+
358
+ def find_entity_in_tree(fullpath, inventory_structure)
359
+ entity = inventory_structure
360
+ if fullpath.resource_ids
361
+ relative = fullpath.resource_ids.drop(1)
362
+ relative.each do |child|
363
+ if (entity.key? 'children') && (entity['children'].key? 'resource')
364
+ unescaped = URI.unescape(child)
365
+ entity = entity['children']['resource'].find { |r| r['data']['id'] == unescaped }
366
+ else
367
+ entity = nil
368
+ break
369
+ end
370
+ end
371
+ end
372
+ if fullpath.metric_id
373
+ if (entity.key? 'children') && (entity['children'].key? 'metric')
374
+ unescaped = URI.unescape(fullpath.metric_id)
375
+ entity = entity['children']['metric'].find { |r| r['data']['id'] == unescaped }
376
+ else
377
+ entity = nil
378
+ end
379
+ end
380
+ entity
381
+ end
382
+
383
+ def extract_child_resources(arr, path, parent_hash, recursive)
384
+ c_path = CanonicalPath.parse_if_string(path)
385
+ if (parent_hash.key? 'children') && (parent_hash['children'].key? 'resource')
386
+ parent_hash['children']['resource'].each do |r|
387
+ entity = entity_json_to_hash(-> (id) { c_path.down(id) }, r, false)
388
+ arr.push(Resource.new(entity))
389
+ extract_child_resources(arr, entity['path'], r, true) if recursive
390
+ end
391
+ end
392
+ arr
393
+ end
394
+
395
+ def extract_resources_for_type(structures, feed_path, resource_type_id, fetch_properties)
396
+ matching_resources = []
397
+ structures.each do |full_struct|
398
+ next unless full_struct.key? 'typesIndex'
399
+ next unless full_struct['typesIndex'].key? resource_type_id
400
+ inventory_structure = full_struct['inventoryStructure']
401
+ root_path = feed_path.down(inventory_structure['data']['id'])
402
+ full_struct['typesIndex'][resource_type_id].each do |relative_path|
403
+ if relative_path.empty?
404
+ # Root resource
405
+ resource = entity_json_to_hash(-> (id) { feed_path.down(id) }, inventory_structure, fetch_properties)
406
+ matching_resources.push(Resource.new(resource))
407
+ else
408
+ # Search for child
409
+ fullpath = CanonicalPath.parse("#{root_path}/#{relative_path}")
410
+ resource_json = find_entity_in_tree(fullpath, inventory_structure)
411
+ if resource_json
412
+ resource = entity_json_to_hash(-> (_) { fullpath }, resource_json, fetch_properties)
413
+ matching_resources.push(Resource.new(resource))
414
+ end
415
+ end
416
+ end
417
+ end
418
+ matching_resources
419
+ end
420
+
421
+ def extract_metrics_for_type(structures, feed_path, metric_type)
422
+ matching_metrics = []
423
+ structures.each do |full_struct|
424
+ next unless full_struct.key? 'metricTypesIndex'
425
+ next unless full_struct['metricTypesIndex'].key? metric_type.id
426
+ inventory_structure = full_struct['inventoryStructure']
427
+ root_path = feed_path.down(inventory_structure['data']['id'])
428
+ full_struct['metricTypesIndex'][metric_type.id].each do |relative_path|
429
+ # Search for child
430
+ fullpath = CanonicalPath.parse("#{root_path}/#{relative_path}")
431
+ metric_json = find_entity_in_tree(fullpath, inventory_structure)
432
+ if metric_json
433
+ metric_hash = entity_json_to_hash(-> (_) { fullpath }, metric_json, false)
434
+ matching_metrics.push(Metric.new(metric_hash, metric_type))
435
+ end
436
+ end
437
+ end
438
+ matching_metrics
439
+ end
440
+
441
+ def extract_structure_from_body(response_body_array)
442
+ # Expecting only 1 structure (but may have several chunks)
443
+ structures = extract_structures_from_body(response_body_array)
444
+ structures[0]['inventoryStructure'] unless structures.empty?
445
+ end
446
+
447
+ def extract_structures_from_body(response_body_array)
448
+ response_body_array.map { |element| rebuild_from_chunks(element['data']) }
449
+ .select { |full| full } # evict nil
450
+ .map { |full| decompress(full) }
451
+ end
452
+
453
+ def rebuild_from_chunks(data_node)
454
+ return if data_node.empty?
455
+ master_data = data_node[0]
456
+ return Base64.decode64(master_data['value']) unless (master_data.key? 'tags') &&
457
+ (master_data['tags'].key? 'chunks')
458
+ last_chunk = master_data['tags']['chunks'].to_i - 1
459
+ all = Base64.decode64(master_data['value'])
460
+ return if all.empty?
461
+ (1..last_chunk).inject(all) do |full, chunk_id|
462
+ slave_data = data_node[chunk_id]
463
+ full.concat(Base64.decode64(slave_data['value']))
464
+ end
465
+ end
466
+
467
+ def decompress(raw)
468
+ gz = Zlib::GzipReader.new(StringIO.new(raw))
469
+ JSON.parse(gz.read)
470
+ end
471
+ end
571
472
  end