Class: Backup

Inherits:
Object
  • Object
show all
Extended by:
RightScale::Api::GatewayExtend
Includes:
RightScale::Api::Gateway
Defined in:
lib/rest_connection/rightscale/backup.rb

Overview

API 1.5

Instance Attribute Summary

Attributes included from RightScale::Api::Base

#params

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RightScale::Api::GatewayExtend

create, filters, find, find_all, find_by, find_with_filter, load, load_all, parse_args, resource_post_name

Methods included from RightScale::Api::GatewayConnection

#connection

Methods included from RightScale::Api::BaseExtend

#[], #create, #deny_methods, #filters, #find, #find_all, #find_by, #find_by_cloud_id, #find_by_id, #find_by_nickname, #find_by_nickname_speed, #find_with_filter, #resource_plural_name, #resource_singular_name

Methods included from RightScale::Api::BaseConnection

#connection

Methods included from RightScale::Api::Gateway

#[], #[]=, #actions, #hash_of_links, #href, #initialize, #load, #method_missing, #nickname, #parse_params, #rediscover, #save

Methods included from RightScale::Api::Base

#[], #[]=, #destroy, #initialize, #method_missing, #reload, #resource_plural_name, #resource_singular_name, #rs_id, #save

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightScale::Api::Gateway

Class Method Details

.cleanup(lineage, keep_last, params = {}) ⇒ Object



65
66
67
68
# File 'lib/rest_connection/rightscale/backup.rb', line 65

def self.cleanup(lineage, keep_last, params={})
  params.merge!('keep_last' => keep_last, 'lineage' => lineage)
  connection.post(resource_plural_name + "/cleanup", params)
end

.filtersObject



33
34
35
# File 'lib/rest_connection/rightscale/backup.rb', line 33

def self.filters
  [:cloud_href, :committed, :completed, :from_master, :latest_before]
end

.find_all(lineage) ⇒ Object



37
38
39
# File 'lib/rest_connection/rightscale/backup.rb', line 37

def self.find_all(lineage)
  index(lineage)
end

.find_with_filter(lineage, filter = {}) ⇒ Object



41
42
43
# File 'lib/rest_connection/rightscale/backup.rb', line 41

def self.find_with_filter(lineage, filter={})
  index(lineage, filter)
end

.index(lineage, filter = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rest_connection/rightscale/backup.rb', line 45

def self.index(lineage, filter={})
  filter_params = []
  filter.each { |key,val|
    unless self.filters.include?(key.to_sym)
      raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}")
    end
    filter_params << "#{key}==#{val}"
  }

  a = Array.new
  url = self.resource_plural_name
  hsh = {'lineage' => lineage}
  hsh.merge(:filter => filter_params) unless filter_params.empty?
  connection.get(url, hsh).each do |object|
    a << self.new(object)
  end

  return a
end

Instance Method Details

#restore(instance_href, name = nil, description = nil) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/rest_connection/rightscale/backup.rb', line 70

def restore(instance_href, name=nil, description=nil)
  uri = URI.parse(self.href)
  params = {'instance_href' => instance_href}
  params.deep_merge!({'backup' => {'name' => name}}) if name
  params.deep_merge!({'backup' => {'description' => description}}) if description
  location = connection.post(uri.path + "/restore", params)
  Task.new('href' => location)
end