lib/hawkular/alerts/alerts_api.rb in hawkular-client-2.8.0 vs lib/hawkular/alerts/alerts_api.rb in hawkular-client-2.9.0

- old
+ new

@@ -11,11 +11,11 @@ # Interface to use to talk to the Hawkular-Alerts component. # @param entrypoint [String] base url of Hawkular-Alerts - e.g # http://localhost:8080/hawkular/alerts # @param credentials [Hash{String=>String}] Hash of username, password, token(optional) # @param options [Hash{String=>String}] Additional rest client options - class AlertsClient < Hawkular::BaseClient + class Client < Hawkular::BaseClient def initialize(entrypoint, credentials = {}, options = {}) entrypoint = normalize_entrypoint_url entrypoint, 'hawkular/alerts' @entrypoint = entrypoint super(entrypoint, credentials, options) @@ -320,10 +320,26 @@ end def delete_event(id) http_delete "/events/#{id}" end + + # Add tags to existing Alerts. + # @param [Array<numeric>] alert_ids List of alert IDs + # @param [Array<String>] tags List of tags. Each tag of format 'name|value'. + def add_tags(alert_ids, tags) + query = generate_query_params(alertIds: alert_ids, tags: tags) + http_put('/tags' + query, {}) + end + + # Remove tags from existing Alerts. + # @param [Array<numeric>] alert_ids List of alert IDs + # @param [Array<String>] tag_names List of tag names. + def remove_tags(alert_ids, tag_names) + query = generate_query_params(alertIds: alert_ids, tagNames: tag_names) + http_delete('/tags' + query) + end end # Representation of one Trigger ## (22 known properties: "enabled", "autoResolveMatch", "name", "memberOf", "autoEnable", # "firingMatch", "tags", "id", "source", "tenantId", "eventText", "context", "eventType", @@ -404,10 +420,11 @@ @trigger_mode = cond_hash['triggerMode'] @data_id = cond_hash['dataId'] @data2_id = cond_hash['data2Id'] @data2_multiplier = cond_hash['data2Multiplier'] @trigger_id = cond_hash['triggerId'] + @interval = cond_hash['interval'] end def to_h cond_hash = {} cond_hash['conditionId'] = @condition_id @@ -418,10 +435,11 @@ cond_hash['triggerMode'] = @trigger_mode cond_hash['dataId'] = @data_id cond_hash['data2Id'] = @data2_id cond_hash['data2Multiplier'] = @data2_multiplier cond_hash['triggerId'] = @trigger_id + cond_hash['interval'] = @interval cond_hash end end # Representing of one GroupConditionsInfo @@ -555,6 +573,9 @@ class Event < OpenStruct def initialize(event_hash) super(event_hash) end end + + AlertsClient = Client + deprecate_constant :AlertsClient if self.respond_to? :deprecate_constant end