require 'fog/core/collection' require 'fog/aws/models/compute/key_pair' module Fog module AWS class Compute class KeyPairs < Fog::Collection attribute :filters attribute :key_name 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})[/]") filters = {'key-name' => [*filters]} end self.filters = filters data = connection.describe_key_pairs(filters).body 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 end end end end end end