Class: Pixela::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/pixela/notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, graph_id:, notification_id:) ⇒ Notification

Returns a new instance of Notification.

Parameters:



18
19
20
21
22
# File 'lib/pixela/notification.rb', line 18

def initialize(client:, graph_id:, notification_id:)
  @client          = client
  @graph_id        = graph_id
  @notification_id = notification_id
end

Instance Attribute Details

#clientPixela::Client (readonly)

Returns:



5
6
7
# File 'lib/pixela/notification.rb', line 5

def client
  @client
end

#graph_idString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/pixela/notification.rb', line 9

def graph_id
  @graph_id
end

#notification_idString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/pixela/notification.rb', line 13

def notification_id
  @notification_id
end

Instance Method Details

#create(name:, target:, condition:, threshold:, remind_by: nil, channel_id:) ⇒ Pixela::Response

Create a notification rule.

Examples:

client.graph("test-graph").notification("my-notification-rule").create(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", remind_by: "21", channel_id: "my-channel")

Parameters:

  • name (String)
  • target (String)
  • condition (String)
  • threshold (String)
  • remind_by (String) (defaults to: nil)
  • channel_id (String)

Returns:

Raises:

See Also:



41
42
43
# File 'lib/pixela/notification.rb', line 41

def create(name:, target:, condition:, threshold:, remind_by: nil, channel_id:)
  client.create_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, remind_by: remind_by, channel_id: channel_id)
end

#deletePixela::Response

Delete predefined notification settings.

Examples:

client.graph("test-graph").notification("my-notification-rule").delete

Returns:

Raises:

See Also:



75
76
77
# File 'lib/pixela/notification.rb', line 75

def delete
  client.delete_notification(graph_id: graph_id, notification_id: notification_id)
end

#update(name:, target:, condition:, threshold:, channel_id:) ⇒ Pixela::Response

Update predefined notification rule.

Examples:

client.graph("test-graph").notification("my-notification-rule").update(name: "my notification rule", target: "quantity", condition: ">", threshold: "5", channel_id: "my-channel")

Parameters:

  • name (String)
  • target (String)
  • condition (String)
  • threshold (String)
  • channel_id (String)

Returns:

Raises:

See Also:



61
62
63
# File 'lib/pixela/notification.rb', line 61

def update(name:, target:, condition:, threshold:, channel_id:)
  client.update_notification(graph_id: graph_id, notification_id: notification_id, name: name, target: target, condition: condition, threshold: threshold, channel_id: channel_id)
end