Sha256: c57d89447faf53ead537cddc4125d33b1529da1ab843e86c42fdb7c8fe54fbc0
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
require 'acquia/cloud/entity' require 'net/http' require 'uri' module Acquia class Cloud class DatabaseBackup < Entity include Operations::Delete def initialize(cloud, site, environment, database, backup) @cloud = cloud @site = site @environment = environment @database = database @data = backup @url = "/sites/#{@site}/envs/#{@environment}/dbs/#{@database}/backups/#{data['id']}" end def id data['id'] end def checksum data['checksum'] end def deleted? data['deleted'] != '0' end def name data['name'] end def path data['path'] end def started Time.at(data['started'].to_i) end def completed Time.at(data['completed'].to_i) end def type data['type'] end def link data['link'] end def download_to(path, &block) uri = URI.parse(link) File.open(path, 'wb') do |io| https = uri.scheme == 'https' Net::HTTP.start(uri.host, uri.port, use_ssl: https) do |http| request = Net::HTTP::Get.new uri request.basic_auth *@cloud.api.credentials http.request request do |response| response.read_body do |chunk| io.write chunk block.call(response, chunk) if block_given? end end end end end def download(&block) download_to(File.basename(path), &block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acquia-cloud-0.5.0 | lib/acquia/cloud/database_backup.rb |