Class: DatabasusRuby::Storages

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

Overview

Backup destinations.

client.storages.save(name: "offsite", type: "S3",
                   workspaceId: id, s3Storage: { ... })

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

Constant Summary collapse

TYPES =

Returns:

  • (Array[String])
%w[LOCAL S3 GOOGLE_DRIVE NAS AZURE_BLOB FTP SFTP RCLONE].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 /storages/id

Parameters:

  • id (String)

Returns:

  • (Boolean)


36
37
38
# File 'lib/databasus_ruby/objects/storages.rb', line 36

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

#direct_test(**attributes) ⇒ Boolean

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

Parameters:

Returns:

  • (Boolean)


46
47
48
# File 'lib/databasus_ruby/objects/storages.rb', line 46

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

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

GET /storages/id

Parameters:

  • id (String)

Returns:



23
24
25
# File 'lib/databasus_ruby/objects/storages.rb', line 23

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

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

GET /storages

Parameters:

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

Returns:



17
18
19
# File 'lib/databasus_ruby/objects/storages.rb', line 17

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

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

POST /storages

Parameters:

Returns:



29
30
31
# File 'lib/databasus_ruby/objects/storages.rb', line 29

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

#test(id) ⇒ Boolean

POST /storages/id/test

Parameters:

  • id (String)

Returns:

  • (Boolean)


41
42
43
# File 'lib/databasus_ruby/objects/storages.rb', line 41

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

#transfer(id, target_workspace_id:) ⇒ Boolean

POST /storages/id/transfer

Parameters:

  • id (String)
  • target_workspace_id: (String)

Returns:

  • (Boolean)


51
52
53
# File 'lib/databasus_ruby/objects/storages.rb', line 51

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