From 8b913d812aef53a984b152db3e42586d4e83ac3b Mon Sep 17 00:00:00 2001 From: mriley Date: Sun, 21 Nov 2010 09:02:34 -0500 Subject: [PATCH] documentation update for key_pairs and helper --- lib/fog/aws/models/compute/key_pairs.rb | 48 +++++++++++++++++++++++++ tests/helper.rb | 4 +++ 2 files changed, 52 insertions(+) diff --git a/lib/fog/aws/models/compute/key_pairs.rb b/lib/fog/aws/models/compute/key_pairs.rb index 1f1b603a1..31657c2f0 100644 --- a/lib/fog/aws/models/compute/key_pairs.rb +++ b/lib/fog/aws/models/compute/key_pairs.rb @@ -12,11 +12,43 @@ module Fog model Fog::AWS::Compute::KeyPair + # Used to create a key pair. There are 3 arguments and only name is required. You can generate a new key_pair as follows: + # AWS.key_pairs.create(:name => "test", :fingerprint => "123", :private_key => '234234') + # + # ==== Returns + # + # + # + # The key_pair can be retreived by running AWS.key_pairs.get("test"). See get method below. + # + def initialize(attributes) self.filters ||= {} super end + # Returns an array of all key pairs that have been created + # + # AWS.key_pairs.all + # + # ==== Returns + # + # + # ] + #> + # + def all(filters = filters) unless filters.is_a?(Hash) Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('key-name' => []) instead[/] [light_black](#{caller.first})[/]") @@ -27,6 +59,22 @@ module Fog load(data['keySet']) end + # Used to retreive a key pair that was created with the AWS.key_pairs.create method. + # The name is required to get the associated key_pair information. + # + # You can run the following command to get the details: + # AWS.key_pairs.get("test") + # + # ==== Returns + # + #>> AWS.key_pairs.get("test") + # + # + def get(key_name) if key_name self.class.new(:connection => connection).all('key-name' => key_name).first diff --git a/tests/helper.rb b/tests/helper.rb index e14723683..476a5ac10 100644 --- a/tests/helper.rb +++ b/tests/helper.rb @@ -24,6 +24,10 @@ require 'tests/helpers/storage/directories_tests' require 'tests/helpers/storage/file_tests' require 'tests/helpers/storage/files_tests' +# Use so you can run in mock mode from the command line: +# +# FOG_MOCK=true fog + if ENV["FOG_MOCK"] == "true" Fog.mock! end