Class: RightScaleAPI::Account

Inherits:
Base
  • Object
show all
Defined in:
lib/right-scale-api/account.rb

Defined Under Namespace

Classes: SubResource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

api_name, attributes, #collection_uri, create, #delete, #destroy, get, #get, #head, #initialize, #path, #post, #put, #reload!, #send_request, #update, #uri

Constructor Details

This class inherits a constructor from RightScaleAPI::Base

Class Method Details

.sub_resources(*resources) ⇒ Object

Creates a method for each passed symbol that grabs the list of objects matching it takes options that are added as query params also does some munging of the opts in particular, :region => :us_east/:us_west/:eu/:ap will map to the proper cloud_id, so you don’t have to remember them



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/right-scale-api/account.rb', line 12

def self.sub_resources *resources
  resources.each do |resource|
    module_eval %(
                  def #{resource} query_opts={}
                    get('/#{resource}.xml', :query => #{resource.to_s.classify}.opts_to_query_opts(query_opts) )['#{resource}'].map do |attrs|
                      #{resource.to_s.classify}.new attrs.merge(:account => self)
                    end
                  end
                  ),__FILE__, __LINE__-6
  end
end

Instance Method Details

#create_deployment(opts) ⇒ Object

Creates a Deployment

Parameters:

  • opts (Hash)

    deployment attributes

Options Hash (opts):

  • :nickname (String)

    The nickname of the deployment

  • :description (String)

    The description of the deployment

  • String (String :default_ec2_availability_zone the default availability zone for the deployment e.g. us-east-1a)

    :default_ec2_availability_zone the default availability zone for the deployment e.g. us-east-1a

  • :default_vpc_subnet_href (String)
  • :region (Symbol) — default: :us_east

    The region to create the IP in. One of :us_east, :eu, :us_west, :ap



41
42
43
# File 'lib/right-scale-api/account.rb', line 41

def create_deployment opts
  Deployment.create opts.merge :account => self
end

#create_ec2_ebs_volume(opts) ⇒ Object

Creates an EC2 EBS Volume

Parameters:

  • opts (Hash)

    volume attributes

Options Hash (opts):

  • :nickname (String)

    The nickname of the volume

  • :description (String)
  • :aws_size (Fixnum)

    The size of the volume in gigabytes*

  • :ec2_availability_zone (String)

    name of the availability zone e.g. us-east-1a*

  • :region (Symbol) — default: :us_east

    The region to create the IP in. One of :us_east, :eu, :us_west, :ap



60
61
62
# File 'lib/right-scale-api/account.rb', line 60

def create_ec2_ebs_volume opts
  Ec2EbsVolume.create opts.merge :account => self
end

#create_ec2_elastic_ip(opts) ⇒ Object

Creates an EC2 EBS Elastic IP

Parameters:

  • opts (Hash)

    ip attributes

Options Hash (opts):

  • :nickname (String)

    The nickname of the ip

  • :region (Symbol) — default: :us_east

    The region to create the IP in. One of :us_east, :eu, :us_west, :ap



49
50
51
# File 'lib/right-scale-api/account.rb', line 49

def create_ec2_elastic_ip opts
  Ec2ElasticIp.create opts.merge :account => self
end

#create_server(opts) ⇒ Object

Creates an EC2 Instance

Parameters:

  • opts (Hash)

    server attributes

Options Hash (opts):

  • :server_template (RightScaleAPI::ServerTemplate)

    the server template to use*

  • [RightScaleAPI::Deployment] ([RightScaleAPI::Deployment] :deployment the deployment to add the instance to.)

    :deployment the deployment to add the instance to.

  • :region (Symbol) — default: :us_east

    The region to create the IP in. One of :us_east, :eu, :us_west, :ap



69
70
71
# File 'lib/right-scale-api/account.rb', line 69

def create_server opts
  Server.create opts.merge :account => self
end

#get_ec2_ssh_key(id) ⇒ Object

Gets an EC2 ssh key. Currently you can’t get a list of ssh keys through the API, so you need to get the id through the web interface. my.rightscale.com/clouds/1/ec2_ssh_keys

Parameters:

  • id

    the id of the ssh key to get



78
79
80
# File 'lib/right-scale-api/account.rb', line 78

def get_ec2_ssh_key id
  Ec2SshKey.new get("/ec2_ssh_keys/#{id}").merge :id => id, :account => self
end