Sha256: c04d6cdb8cdbfa01831424121863780c5806f37068b3e1d9e1f02937b9b7b73c

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 Bytes

Contents

require 'fog/huaweicloud/models/collection'
require 'fog/compute/huaweicloud/models/key_pair'

module Fog
  module Compute
    class HuaweiCloud
      class KeyPairs < Fog::HuaweiCloud::Collection
        model Fog::Compute::HuaweiCloud::KeyPair

        def all(options = {})
          items = []
          service.list_key_pairs(options).body['keypairs'].each do |kp|
            items += kp.values
          end
          # TODO: convert to load_response?
          load(items)
        end

        def get(key_pair_name)
          if key_pair_name
            all.select { |kp| kp.name == key_pair_name }.first
          end
        rescue Fog::Compute::HuaweiCloud::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/compute/huaweicloud/models/key_pairs.rb
fog-huaweicloud-0.0.2 lib/fog/compute/huaweicloud/models/key_pairs.rb
fog-huaweicloud-0.1.3 lib/fog/compute/huaweicloud/models/key_pairs.rb
fog-huaweicloud-0.1.2 lib/fog/compute/huaweicloud/models/key_pairs.rb