Sha256: cc34ca6029f1720f362e6e87603409140fed5ba9c49b874879b2c7ff0ba10d83

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

class Sysdig::UserNotifications < Sysdig::Singular

  attribute :sns_enabled, type: :boolean, squash: ["sns", "enabled"]
  attribute :sns_topics,  type: :array, squash: ["sns", "topics"]

  attribute :email_enabled,    type: :boolean, squash: ["email", "enabled"]
  attribute :email_recipients, type: :array, squash: ["email", "recipients"]

  attribute :pager_duty_enabled,         type: :boolean, squash: ["pagerDuty", "enabled"]
  attribute :pager_duty_integrated,      type: :boolean, squash: ["pagerDuty", "integrated"]
  attribute :pager_duty_bind_resolution, type: :boolean, squash: ["pagerDuty", "resolveOnOk"]
  attribute :pager_duty_connect_url,     squash: ["pagerDuty", "connectUrl"]

  def fetch_attributes(options={})
    service.get_user_notifications.body.fetch("userNotification")
  end

  def save
    data = service.update_user_notifications(
      "sns" => {
        "enabled" => self.sns_enabled,
        "topics"  => self.sns_topics,
      },
      "email" => {
        "enabled"    => self.email_enabled,
        "recipients" => self.email_recipients,
      },
      "pagerDuty" => {
        "enabled"     => self.pager_duty_enabled,
        "integrated"  => self.pager_duty_integrated,
        "resolveOnOk" => self.pager_duty_bind_resolution,
        "connectUrl"  => self.pager_duty_connect_url,
      },
    ).body.fetch("userNotification")

    merge_attributes(data)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sysdig-0.3.1 lib/sysdig/user_notifications.rb
sysdig-0.3.0 lib/sysdig/user_notifications.rb
sysdig-0.2.4 lib/sysdig/user_notifications.rb