Sha256: b8a0a75a478b35b2ac9f40b2128c57805511621caf98c61cb30c58d9b39d19e0

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

module Fog
  module Compute
    class DigitalOceanV2
      class SshKeys < Fog::Collection
        model Fog::Compute::DigitalOceanV2::SshKey

        # Returns list of ssh keys
        # @return [Fog::Compute::DigitalOceanV2::Sshkeys] Retrieves a list of ssh keys.
        # @raise [Fog::Compute::DigitalOceanV2::NotFound] - HTTP 404
        # @raise [Fog::Compute::DigitalOceanV2::BadRequest] - HTTP 400
        # @raise [Fog::Compute::DigitalOceanV2::InternalServerError] - HTTP 500
        # @raise [Fog::Compute::DigitalOceanV2::ServiceError]
        # @see https://developers.digitalocean.com/documentation/v2/#list-all-keys
        def all(filters={})
          data = service.list_ssh_keys.body['ssh_keys']
          load(data)
        end

        # Returns ssh key
        # @return [Fog::Compute::DigitalOceanV2::Sshkeys] Retrieves a list of ssh keys.
        # @raise [Fog::Compute::DigitalOceanV2::NotFound] - HTTP 404
        # @raise [Fog::Compute::DigitalOceanV2::BadRequest] - HTTP 400
        # @raise [Fog::Compute::DigitalOceanV2::InternalServerError] - HTTP 500
        # @raise [Fog::Compute::DigitalOceanV2::ServiceError]
        # @see https://developers.digitalocean.com/documentation/v2/#retrieve-an-existing-key
        def get(id)
          key = service.get_ssh_key(id).body['ssh_key']
          new(key) if key
        rescue Fog::Errors::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-1.37.0 lib/fog/digitalocean/models/compute_v2/ssh_keys.rb
fog-1.36.0 lib/fog/digitalocean/models/compute_v2/ssh_keys.rb
fog-1.35.0 lib/fog/digitalocean/models/compute_v2/ssh_keys.rb