Class: RightScaleAPI::Account

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

Defined Under Namespace

Classes: SubResource

Instance Attribute Summary

Attributes inherited from Base

#href, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

This class inherits a constructor from RightScaleAPI::Base

Class Method Details

.sub_resources(*resources) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/right-scale-api/account.rb', line 6

def self.sub_resources *resources
  resources.each do |resource|
    module_eval %(
                  def #{resource}
                    get('/#{resource}.xml')['#{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)


34
35
36
# File 'lib/right-scale-api/account.rb', line 34

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*



52
53
54
# File 'lib/right-scale-api/account.rb', line 52

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

  • :cloud_id (Fixnum)

    the cloud identifier default 1 (1 = us-east; 2 = eu; 3 = us-west, 4 = ap)



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

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

  • [RightScaleAPI::ServerTemplate] (Hash)

    a customizable set of options

  • [[RightScaleAPI::Deployment] (Hash)

    a customizable set of options



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

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



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

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