diff --git a/lib/fog/aws/models/compute/addresses.rb b/lib/fog/aws/models/compute/addresses.rb index 9e9252987..8802c0f15 100644 --- a/lib/fog/aws/models/compute/addresses.rb +++ b/lib/fog/aws/models/compute/addresses.rb @@ -11,12 +11,49 @@ module Fog attribute :server model Fog::AWS::Compute::Address + + # Used to create an IP address + # + # ==== Returns + # + #>> AWS.addresses.create + # + # + # The IP address can be retreived by running AWS.addresses.get("test"). See get method below. + # def initialize(attributes) self.filters ||= {} super end + # AWS.addresses.all + # + # ==== Returns + # + # Returns an array of all IP addresses + # + #>> AWS.addresses.all + # , + # ....... + # + # ] + # > + #>> + def all(filters = filters) unless filters.is_a?(Hash) Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('public-ip' => []) instead[/] [light_black](#{caller.first})[/]") @@ -35,6 +72,13 @@ module Fog self end + # Used to retreive an IP address + # + # public_ip is required to get the associated IP information. + # + # You can run the following command to get the details: + # AWS.addresses.get("76.7.46.54") + def get(public_ip) if public_ip self.class.new(:connection => connection).all('public-ip' => public_ip).first diff --git a/lib/fog/aws/models/compute/flavors.rb b/lib/fog/aws/models/compute/flavors.rb index 494afd65c..31d06c185 100644 --- a/lib/fog/aws/models/compute/flavors.rb +++ b/lib/fog/aws/models/compute/flavors.rb @@ -9,9 +9,9 @@ module Fog model Fog::AWS::Compute::Flavor - # Returns an array of all key pairs that have been created + # Returns an array of all flavors that have been created # - # AWS.key_pairs.all + # AWS.flavors.all # # ==== Returns # @@ -28,78 +28,7 @@ module Fog # name="Micro Instance", # ram=613 # >, - # , - # , - # , - # , - # , - # , - # , - # , - # , + # .... # > AWS.images.new + # + # + def initialize(attributes) self.filters ||= {} super end - + def all(filters = @filters) self.filters = filters data = connection.describe_images(filters).body load(data['imagesSet']) end - + def get(image_id) if image_id self.class.new(:connection => connection).all('image-id' => image_id).first diff --git a/lib/fog/aws/models/compute/security_groups.rb b/lib/fog/aws/models/compute/security_groups.rb index 903e2f1c4..400a7193b 100644 --- a/lib/fog/aws/models/compute/security_groups.rb +++ b/lib/fog/aws/models/compute/security_groups.rb @@ -11,10 +11,49 @@ module Fog model Fog::AWS::Compute::SecurityGroup + # Creates a new security group + # + # AWS.security_groups.new + # + # ==== Returns + # + # Returns the details of the new image + # + #>> AWS.security_groups.new + # + # + def initialize(attributes) self.filters ||= {} super end + + # Returns an array of all security groups that have been created + # + # AWS.security_groups.all + # + # ==== Returns + # + # Returns an array of all security groups + # + #>> AWS.security_groups.all + # [{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>-1, "toPort"=>-1, "ipRanges"=>[], "ipProtocol"=>"icmp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"tcp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"udp"}], + # owner_id="312571045469" + # > + # ] + # > + # def all(filters = filters) unless filters.is_a?(Hash) @@ -26,6 +65,23 @@ module Fog load(data['securityGroupInfo']) end + # Used to retreive a security group + # group name is required to get the associated flavor information. + # + # You can run the following command to get the details: + # AWS.security_groups.get("default") + # + # ==== Returns + # + #>> AWS.security_groups.get("default") + # [{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>-1, "toPort"=>-1, "ipRanges"=>[], "ipProtocol"=>"icmp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"tcp"}, {"groups"=>[{"groupName"=>"default", "userId"=>"312571045469"}], "fromPort"=>0, "toPort"=>65535, "ipRanges"=>[], "ipProtocol"=>"udp"}], + # owner_id="312571045469" + # > + # + def get(group_name) if group_name self.class.new(:connection => connection).all('group-name' => group_name).first diff --git a/lib/fog/aws/models/compute/servers.rb b/lib/fog/aws/models/compute/servers.rb index ad6d44b85..173fbe524 100644 --- a/lib/fog/aws/models/compute/servers.rb +++ b/lib/fog/aws/models/compute/servers.rb @@ -11,6 +11,45 @@ module Fog model Fog::AWS::Compute::Server + # Creates a new server + # + # AWS.servers.new + # + # ==== Returns + # + # Returns the details of the new server + # + #>> AWS.servers.new + # + # + def initialize(attributes) self.filters ||= {} super @@ -64,6 +103,46 @@ module Fog server end + # Used to retreive a server + # + # server_id is required to get the associated server information. + # + # You can run the following command to get the details: + # AWS.servers.get("i-5c973972") + # + # ==== Returns + # + #>> AWS.servers.get("i-5c973972") + # + # + def get(server_id) if server_id self.class.new(:connection => connection).all('instance-id' => server_id).first diff --git a/lib/fog/aws/models/compute/snapshots.rb b/lib/fog/aws/models/compute/snapshots.rb index cc39a653a..f532777c6 100644 --- a/lib/fog/aws/models/compute/snapshots.rb +++ b/lib/fog/aws/models/compute/snapshots.rb @@ -30,7 +30,7 @@ module Fog end self end - + def get(snapshot_id) if snapshot_id self.class.new(:connection => connection).all('snapshot-id' => snapshot_id).first diff --git a/lib/fog/aws/models/compute/tags.rb b/lib/fog/aws/models/compute/tags.rb index 91f1e3e6e..69fe22ea3 100644 --- a/lib/fog/aws/models/compute/tags.rb +++ b/lib/fog/aws/models/compute/tags.rb @@ -21,7 +21,7 @@ module Fog data = connection.describe_tags(filters).body load(data['tagSet']) end - + def get(key) if key self.class.new(:connection => connection).all('key' => key) diff --git a/lib/fog/aws/models/compute/volumes.rb b/lib/fog/aws/models/compute/volumes.rb index f631943ba..9f2a02404 100644 --- a/lib/fog/aws/models/compute/volumes.rb +++ b/lib/fog/aws/models/compute/volumes.rb @@ -44,6 +44,7 @@ module Fog # # ==== Returns # + #>>AWS.volumes.all #: # * 'imageId'<~String> - The ID of the created AMI. # * 'requestId'<~String> - Id of request. + def create_image(instance_id, name, description, no_reboot = false) request( 'Action' => 'CreateImage', @@ -31,7 +32,12 @@ module Fog end class Mock - + + # Usage + # + # AWS[:compute].create_image("i-ac65ee8c", "test", "something") + # + def create_image(instance_id, name, description, no_reboot = false) response = Excon::Response.new if instance_id && !name.empty? diff --git a/lib/fog/aws/requests/compute/create_snapshot.rb b/lib/fog/aws/requests/compute/create_snapshot.rb index 94596fafe..9240463dc 100644 --- a/lib/fog/aws/requests/compute/create_snapshot.rb +++ b/lib/fog/aws/requests/compute/create_snapshot.rb @@ -31,7 +31,13 @@ module Fog end class Mock - + + # + # Usage + # + # AWS[:compute].create_snapshot("vol-f7c23423", "latest snapshot") + # + def create_snapshot(volume_id, description = nil) response = Excon::Response.new if volume = @data[:volumes][volume_id]