Module: Pixela::Client::NotificationMethods

Included in:
Pixela::Client
Defined in:
lib/pixela/client/notificaton_methods.rb

Instance Method Summary collapse

Instance Method Details

#create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, remind_by: nil, channel_id:) ⇒ Pixela::Response

Create a notification rule.

Examples:

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

Parameters:

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

Returns:

Raises:

See Also:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pixela/client/notificaton_methods.rb', line 21

def create_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, remind_by: nil, channel_id:)
  params = {
    id: notification_id,
    name: name,
    target: target,
    condition: condition,
    threshold: threshold,
    remindBy: remind_by,
    channelID: channel_id,
  }

  with_error_handling do
    connection.post("users/#{username}/graphs/#{graph_id}/notifications", compact_hash(params)).body
  end
end

#delete_notification(graph_id:, notification_id:) ⇒ Pixela::Response

Delete predefined notification settings.

Examples:

client.delete_notification(graph_id: "test-graph", notification_id: "my-notification-rule")

Parameters:

  • graph_id (String)
  • notification_id (String)

Returns:

Raises:

See Also:



100
101
102
103
104
# File 'lib/pixela/client/notificaton_methods.rb', line 100

def delete_notification(graph_id:, notification_id:)
  with_error_handling do
    connection.delete("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}").body
  end
end

#get_notifications(graph_id:) ⇒ Array<Pixela::Response>

Get all predefined notifications.

Examples:

client.get_notifications(graph_id: "test-graph")

Parameters:

  • graph_id (String)

Returns:

Raises:

See Also:



49
50
51
52
53
# File 'lib/pixela/client/notificaton_methods.rb', line 49

def get_notifications(graph_id:)
  with_error_handling do
    connection.get("users/#{username}/graphs/#{graph_id}/notifications").body.notifications
  end
end

#update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:) ⇒ Pixela::Response

Update predefined notification rule.

Examples:

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

Parameters:

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

Returns:

Raises:

See Also:



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/pixela/client/notificaton_methods.rb', line 73

def update_notification(graph_id:, notification_id:, name:, target:, condition:, threshold:, channel_id:)
  params = {
    name: name,
    target: target,
    condition: condition,
    threshold: threshold,
    channelID: channel_id,
  }

  with_error_handling do
    connection.put("users/#{username}/graphs/#{graph_id}/notifications/#{notification_id}", compact_hash(params)).body
  end
end