Class: DatabasusRuby::Notifiers

Inherits:
Object
  • Object
show all
Includes:
Endpoint
Defined in:
lib/databasus_ruby/objects/notifiers.rb,
sig/databasus_ruby.rbs

Overview

Notification channels.

client.notifiers.save(name: "ops", notifierType: "SLACK",
                    workspaceId: id, slackNotifier: { ... })

POST /notifiers both creates and updates: include id in the payload to update an existing notifier.

Constant Summary collapse

TYPES =

Returns:

  • (Array[String])
%w[EMAIL TELEGRAM WEBHOOK SLACK DISCORD TEAMS].freeze
NOTIFICATION_TYPES =

Returns:

  • (Array[String])
%w[
  ALL BACKUP_SUCCESS BACKUP_FAILED HEALTHCHECK_SUCCESS HEALTHCHECK_FAILED
  VERIFICATION_SUCCESS VERIFICATION_FAILED
].freeze

Instance Attribute Summary

Attributes included from Endpoint

#client

Instance Method Summary collapse

Methods included from Endpoint

#acknowledged, #build, #collection, #compact, #escape, #http_delete, #http_get, #http_post, #http_put, #initialize, #inspect, #object, #single_value, #with_default_workspace

Methods inherited from Object

#==, #[], #hash, #initialize, #inspect, #key?, #keys, #method_missing, #respond_to_missing?, #to_h

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class DatabasusRuby::Object

Instance Method Details

#delete(id) ⇒ Boolean

DELETE /notifiers/id

Parameters:

  • id (String)

Returns:

  • (Boolean)


40
41
42
# File 'lib/databasus_ruby/objects/notifiers.rb', line 40

def delete(id)
  acknowledged(http_delete("notifiers/#{escape(id)}"))
end

#direct_test(**attributes) ⇒ Boolean

POST /notifiers/direct-test — tests a payload that has not been saved yet.

Parameters:

Returns:

  • (Boolean)


50
51
52
# File 'lib/databasus_ruby/objects/notifiers.rb', line 50

def direct_test(**attributes)
  acknowledged(http_post("notifiers/direct-test", attributes))
end

#get(id) ⇒ Object Also known as: find

GET /notifiers/id

Parameters:

  • id (String)

Returns:



27
28
29
# File 'lib/databasus_ruby/objects/notifiers.rb', line 27

def get(id)
  object(http_get("notifiers/#{escape(id)}"))
end

#list(workspace_id: nil) ⇒ Collection Also known as: all

GET /notifiers

Parameters:

  • workspace_id: (String, nil) (defaults to: nil)

Returns:



21
22
23
# File 'lib/databasus_ruby/objects/notifiers.rb', line 21

def list(workspace_id: nil)
  collection(http_get("notifiers", { workspace_id: workspace_id || client.workspace_id! }), key: "notifiers")
end

#save(**attributes) ⇒ Object Also known as: create, update

POST /notifiers

Parameters:

Returns:



33
34
35
# File 'lib/databasus_ruby/objects/notifiers.rb', line 33

def save(**attributes)
  object(http_post("notifiers", with_default_workspace(attributes)))
end

#test(id) ⇒ Boolean

POST /notifiers/id/test — sends a test notification.

Parameters:

  • id (String)

Returns:

  • (Boolean)


45
46
47
# File 'lib/databasus_ruby/objects/notifiers.rb', line 45

def test(id)
  acknowledged(http_post("notifiers/#{escape(id)}/test"))
end

#transfer(id, target_workspace_id:) ⇒ Boolean

POST /notifiers/id/transfer

Parameters:

  • id (String)
  • target_workspace_id: (String)

Returns:

  • (Boolean)


55
56
57
# File 'lib/databasus_ruby/objects/notifiers.rb', line 55

def transfer(id, target_workspace_id:)
  acknowledged(http_post("notifiers/#{escape(id)}/transfer", { targetWorkspaceId: target_workspace_id }))
end