Class: SFRest::Backup
- Inherits:
-
Object
- Object
- SFRest::Backup
- Defined in:
- lib/sfrest/backup.rb
Overview
Backup a site or restore onto that site
Instance Method Summary collapse
-
#backup_url(site_id, backup_id, lifetime = 60) ⇒ Object
Gets a url to download a backup.
-
#create_backup(site_id, datum = nil) ⇒ Object
Backs up a site.
-
#delete_backup(site_id, backup_id) ⇒ Object
Deletes a site backup.
-
#expiration_get ⇒ Hash
Gets the current the backup expiration and automatic deletion setting.
-
#expiration_set(days) ⇒ Object
Configures the backup expiration and automatic deletion setting.
-
#get_backups(site_id, datum = nil) ⇒ Hash
cool stuff goes here.
-
#initialize(conn) ⇒ Backup
constructor
A new instance of Backup.
Constructor Details
#initialize(conn) ⇒ Backup
Returns a new instance of Backup.
7 8 9 |
# File 'lib/sfrest/backup.rb', line 7 def initialize(conn) @conn = conn end |
Instance Method Details
#backup_url(site_id, backup_id, lifetime = 60) ⇒ Object
Gets a url to download a backup
44 45 46 |
# File 'lib/sfrest/backup.rb', line 44 def backup_url(site_id, backup_id, lifetime = 60) @conn.get("/api/v1/sites/#{site_id}/backups/#{backup_id}/url?lifetime=#{lifetime}") end |
#create_backup(site_id, datum = nil) ⇒ Object
Backs up a site.
35 36 37 38 |
# File 'lib/sfrest/backup.rb', line 35 def create_backup(site_id, datum = nil) current_path = "/api/v1/sites/#{site_id}/backup" @conn.post(current_path, datum.to_json) end |
#delete_backup(site_id, backup_id) ⇒ Object
Deletes a site backup.
23 24 25 26 |
# File 'lib/sfrest/backup.rb', line 23 def delete_backup(site_id, backup_id) current_path = "/api/v1/sites/#{site_id}/backups/#{backup_id}" @conn.delete(current_path) end |
#expiration_get ⇒ Hash
Gets the current the backup expiration and automatic deletion setting.
59 60 61 |
# File 'lib/sfrest/backup.rb', line 59 def expiration_get @conn.get('/api/v1/backup-expiration/') end |
#expiration_set(days) ⇒ Object
Configures the backup expiration and automatic deletion setting.
50 51 52 53 54 55 |
# File 'lib/sfrest/backup.rb', line 50 def expiration_set(days) payload = { 'expiration_days' => days } @conn.put('/api/v1/backup-expiration/', payload.to_json) end |
#get_backups(site_id, datum = nil) ⇒ Hash
cool stuff goes here
14 15 16 17 18 |
# File 'lib/sfrest/backup.rb', line 14 def get_backups(site_id, datum = nil) current_path = "/api/v1/sites/#{site_id}/backups" pb = SFRest::Pathbuilder.new @conn.get URI.parse(pb.build_url_query(current_path, datum)).to_s end |