Sha256: a745f12372d4cb671d0232c57ff30f74953f3a64031b34fc06329437441fae9b

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

require 'fog/digitalocean/models/paging_collection'

module Fog
  module Compute
    class DigitalOcean
      class SshKeys < Fog::Compute::DigitalOcean::PagingCollection
        model Fog::Compute::DigitalOcean::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(filters)
          links = data.body["links"]
          get_paged_links(links)
          keys = data.body["ssh_keys"]
          load(keys)
        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

6 entries across 4 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/models/compute/ssh_keys.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/models/compute/ssh_keys.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-digitalocean-0.3.0/lib/fog/digitalocean/models/compute/ssh_keys.rb
fog-digitalocean-0.3.0 lib/fog/digitalocean/models/compute/ssh_keys.rb
fog-digitalocean-0.2.0 lib/fog/digitalocean/models/compute/ssh_keys.rb
fog-digitalocean-0.1.0 lib/fog/digitalocean/models/compute/ssh_keys.rb