Class: DatabasusRuby::Databases
- Includes:
- Endpoint
- Defined in:
- lib/databasus_ruby/objects/databases.rb,
sig/databasus_ruby.rbs
Overview
Databases under backup.
client.databases.list(workspace_id: id)
client.databases.create(name: "primary", type: "POSTGRES_LOGICAL",
workspaceId: id, postgresqlLogical: { ... })
The create/update bodies are the full databases.Database payload, whose
engine-specific half lives under one of postgresqlLogical,
postgresqlPhysical, mysql, mariadb or mongodb.
Constant Summary collapse
- TYPES =
%w[POSTGRES_LOGICAL POSTGRES_PHYSICAL MYSQL MARIADB MONGODB].freeze
- HEALTH_STATUSES =
%w[AVAILABLE UNAVAILABLE].freeze
Instance Attribute Summary
Attributes included from Endpoint
Instance Method Summary collapse
- #backup(id) ⇒ Object
-
#backups(id, **filters) ⇒ Collection
The backups of one database by id.
-
#copy(id) ⇒ Database
POST /databases/id/copy.
-
#create(**attributes) ⇒ Database
POST /databases/create.
-
#create_readonly_user(**attributes) ⇒ Object
POST /databases/create-readonly-user -> { username, password }.
-
#create_replication_only_user(**attributes) ⇒ Object
POST /databases/create-replication-only-user (PostgreSQL physical only).
-
#delete(id) ⇒ Boolean
DELETE /databases/id.
-
#get(id) ⇒ Database
(also: #find)
GET /databases/id.
-
#list(workspace_id: nil) ⇒ Collection
(also: #all)
GET /databases.
-
#notifier_databases_count(notifier_id) ⇒ Object
GET /databases/notifier/id/databases-count.
-
#notifier_using?(notifier_id) ⇒ Boolean
GET /databases/notifier/id/is-using.
-
#readonly(**attributes) ⇒ Object
POST /databases/is-readonly -> { isReadOnly, privileges }.
- #readonly?(**attributes) ⇒ Boolean
-
#test_connection(id) ⇒ Boolean
POST /databases/id/test-connection — true when the database answers.
-
#test_connection_direct(**attributes) ⇒ Boolean
POST /databases/test-connection-direct — tests a payload that has not been saved yet.
-
#update(**attributes) ⇒ Database
POST /databases/update — the id travels in the body, not the path.
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
#backup(id) ⇒ Object
93 94 95 |
# File 'lib/databasus_ruby/objects/databases.rb', line 93 def backup(id) client.backups.create(database_id: require_id(id)) end |
#backups(id, **filters) ⇒ Collection
The backups of one database by id. A database returned by this endpoint answers the same two methods without the id — see Database.
client.databases.backups(database.id, status: "COMPLETED")
client.databases.backup(database.id) # queue a run
#backups takes the same filters as Backups#list.
89 90 91 |
# File 'lib/databasus_ruby/objects/databases.rb', line 89 def backups(id, **filters) client.backups.list(database_id: require_id(id), **filters) end |
#copy(id) ⇒ Database
POST /databases/id/copy
48 49 50 |
# File 'lib/databasus_ruby/objects/databases.rb', line 48 def copy(id) object(http_post("databases/#{escape(id)}/copy"), as: Database) end |
#create(**attributes) ⇒ Database
POST /databases/create
33 34 35 |
# File 'lib/databasus_ruby/objects/databases.rb', line 33 def create(**attributes) object(http_post("databases/create", with_default_workspace(attributes)), as: Database) end |
#create_readonly_user(**attributes) ⇒ Object
POST /databases/create-readonly-user -> { username, password }
64 65 66 |
# File 'lib/databasus_ruby/objects/databases.rb', line 64 def create_readonly_user(**attributes) object(http_post("databases/create-readonly-user", attributes)) end |
#create_replication_only_user(**attributes) ⇒ Object
POST /databases/create-replication-only-user (PostgreSQL physical only)
69 70 71 |
# File 'lib/databasus_ruby/objects/databases.rb', line 69 def create_replication_only_user(**attributes) object(http_post("databases/create-replication-only-user", attributes)) end |
#delete(id) ⇒ Boolean
DELETE /databases/id
43 44 45 |
# File 'lib/databasus_ruby/objects/databases.rb', line 43 def delete(id) acknowledged(http_delete("databases/#{escape(id)}")) end |
#get(id) ⇒ Database Also known as: find
GET /databases/id
27 28 29 |
# File 'lib/databasus_ruby/objects/databases.rb', line 27 def get(id) object(http_get("databases/#{escape(id)}"), as: Database) end |
#list(workspace_id: nil) ⇒ Collection Also known as: all
GET /databases
20 21 22 23 |
# File 'lib/databasus_ruby/objects/databases.rb', line 20 def list(workspace_id: nil) collection(http_get("databases", { workspace_id: workspace_id || client.workspace_id! }), key: "databases", as: Database) end |
#notifier_databases_count(notifier_id) ⇒ Object
GET /databases/notifier/id/databases-count
98 99 100 |
# File 'lib/databasus_ruby/objects/databases.rb', line 98 def notifier_databases_count(notifier_id) single_value(http_get("databases/notifier/#{escape(notifier_id)}/databases-count")) end |
#notifier_using?(notifier_id) ⇒ Boolean
GET /databases/notifier/id/is-using
103 104 105 |
# File 'lib/databasus_ruby/objects/databases.rb', line 103 def notifier_using?(notifier_id) single_value(http_get("databases/notifier/#{escape(notifier_id)}/is-using")) == true end |
#readonly(**attributes) ⇒ Object
POST /databases/is-readonly -> { isReadOnly, privileges }
74 75 76 |
# File 'lib/databasus_ruby/objects/databases.rb', line 74 def readonly(**attributes) object(http_post("databases/is-readonly", attributes)) end |
#readonly?(**attributes) ⇒ Boolean
78 79 80 |
# File 'lib/databasus_ruby/objects/databases.rb', line 78 def readonly?(**attributes) readonly(**attributes).isReadOnly == true end |
#test_connection(id) ⇒ Boolean
POST /databases/id/test-connection — true when the database answers.
53 54 55 |
# File 'lib/databasus_ruby/objects/databases.rb', line 53 def test_connection(id) acknowledged(http_post("databases/#{escape(id)}/test-connection")) end |
#test_connection_direct(**attributes) ⇒ Boolean
POST /databases/test-connection-direct — tests a payload that has not been saved yet.
59 60 61 |
# File 'lib/databasus_ruby/objects/databases.rb', line 59 def test_connection_direct(**attributes) acknowledged(http_post("databases/test-connection-direct", attributes)) end |