Class: Fog::AWS::EC2::KeyPairs
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::EC2::KeyPairs
- Defined in:
- lib/fog/aws/models/ec2/key_pairs.rb
Instance Method Summary collapse
- #all(key_name = @key_name) ⇒ Object
- #get(key_name) ⇒ Object
-
#initialize(attributes) ⇒ KeyPairs
constructor
A new instance of KeyPairs.
Methods inherited from Collection
#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #inspect, #load, #merge_attributes, model, #model, #new, #reload, #table, #to_json
Constructor Details
#initialize(attributes) ⇒ KeyPairs
Returns a new instance of KeyPairs.
26 27 28 29 |
# File 'lib/fog/aws/models/ec2/key_pairs.rb', line 26 def initialize(attributes) @key_name ||= [] super end |
Instance Method Details
#all(key_name = @key_name) ⇒ Object
31 32 33 34 35 |
# File 'lib/fog/aws/models/ec2/key_pairs.rb', line 31 def all(key_name = @key_name) @key_name = key_name data = connection.describe_key_pairs(key_name).body load(data['keySet']) end |
#get(key_name) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/fog/aws/models/ec2/key_pairs.rb', line 37 def get(key_name) if key_name all(key_name).first end rescue Excon::Errors::BadRequest nil end |