Sha256: 3d2a45d6f9129903174fbe35a6be94e17fbf3b48c61623e7bcbc216442aba8bd

Contents?: true

Size: 674 Bytes

Versions: 4

Compression:

Stored size: 674 Bytes

Contents

# frozen_string_literal: true

module Hcloud
  class FloatingIPResource < AbstractResource
    filter_attributes :name

    bind_to FloatingIP

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

    def create(type:, server: nil, home_location: nil, description: nil)
      prepare_request(
        'floating_ips', j: COLLECT_ARGS.call(__method__, binding),
                        expected_code: 201
      ) do |response|
        action = Action.new(client, response[:action]) if response[:action]
        [action, FloatingIP.new(client, response[:floating_ip])]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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