require 'fog/core/collection' require 'fog/aws/models/compute/key_pair' module Fog module Compute class AWS class KeyPairs < Fog::Collection attribute :filters attribute :key_name model Fog::Compute::AWS::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 retrieved 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) Fog::Logger.deprecation("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 = service.describe_key_pairs(filters).body load(data['keySet']) end # Used to retrieve 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(:service => service).all('key-name' => key_name).first end end end end end end