lib/sysdig/alert.rb in sysdig-0.1.0 vs lib/sysdig/alert.rb in sysdig-0.2.0
- old
+ new
@@ -17,35 +17,46 @@
attribute :condition
attribute :created_at, alias: "createdOn", parser: method(:epoch_time)
attribute :description
attribute :enabled, type: :boolean, default: true
attribute :filter, parser: lambda { |v, _| load_filter(v) }
- attribute :group_aggregations, type: :array, alias: "groupAggregations"
- attribute :group_by, type: :array, alias: "groupBy"
+ attribute :group_aggregations, type: :array, alias: "groupAggregations"
+ attribute :group_by, type: :array, alias: "groupBy"
attribute :group_condition, alias: "groupCondition"
attribute :modified_at, alias: "modifiedOn", parser: method(:epoch_time)
attribute :name
- attribute :notification_count, type: :integer, alias: "notificationCount"
+ attribute :notification_count, type: :integer, alias: "notificationCount"
attribute :notify, parser: lambda { |v, _| Array(v).map { |x| x.upcase } }
attribute :severity, type: :integer
attribute :segment_by, alias: "segmentBy"
attribute :segment_condition, alias: "segmentCondition"
attribute :targets, type: :array
attribute :timespan, type: :integer
attribute :type, parser: lambda { |v, _| v.to_s.upcase }
attribute :version, type: :integer
+ def destroy
+ requires :identity
+
+ service.destroy_alert(identity)
+ end
+
def save
params = {
- "name" => self.name,
- "description" => self.description,
- "enabled" => self.enabled,
- "filter" => self.class.dump_filter(filter || {}),
- "type" => self.type,
- "condition" => self.condition,
- "timespan" => self.timespan,
- "severity" => self.severity,
- "notify" => self.notify,
+ "condition" => self.condition,
+ "description" => self.description,
+ "enabled" => self.enabled,
+ "filter" => self.class.dump_filter(filter || {}),
+ "groupAggregations" => self.group_aggregations,
+ "groupBy" => self.group_by,
+ "groupCondition" => self.group_condition,
+ "name" => self.name,
+ "notify" => self.notify,
+ "segmentBy" => self.segment_by,
+ "segmentCondition" => self.segment_condition,
+ "severity" => self.severity,
+ "timespan" => self.timespan,
+ "type" => self.type,
}
data = (
(new_record? && service.create_alert(params)) ||
service.update_alert(self.identity, params.merge("version" => self.version))