Sha256: 6e63f8dfb9ba0c4828c92a5f0084b1f8235372aa0da6e2283d7186c484bcc877

Contents?: true

Size: 547 Bytes

Versions: 1

Compression:

Stored size: 547 Bytes

Contents

# frozen_string_literal: true

module Hcloud
  class SSHKeyResource < AbstractResource
    filter_attributes :name, :label_selector

    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:, labels: {})
      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

1 entries across 1 versions & 1 rubygems

Version Path
hcloud-1.1.0 lib/hcloud/ssh_key_resource.rb