Sha256: 30194bec89362c338632501043d3023d2a8ccfa04691976d2a805aed52ac08d6

Contents?: true

Size: 518 Bytes

Versions: 4

Compression:

Stored size: 518 Bytes

Contents

# frozen_string_literal: true

module Hcloud
  class SSHKeyResource < AbstractResource
    filter_attributes :name

    def [](arg)
      case arg
      when Integer then find_by(id: arg)
      when String then find_by(name: arg)
      end
    end

    def create(name:, public_key:)
      prepare_request(
        'ssh_keys', j: COLLECT_ARGS.call(__method__, binding),
                    expected_code: 201
      ) do |response|
        SSHKey.new(client, response.parsed_json[:ssh_key])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hcloud-1.0.3 lib/hcloud/ssh_key_resource.rb
hcloud-1.0.2 lib/hcloud/ssh_key_resource.rb
hcloud-1.0.1 lib/hcloud/ssh_key_resource.rb
hcloud-1.0.0 lib/hcloud/ssh_key_resource.rb