Sha256: bcc05f0438b4cb9f03b08990872b3f6fbcf3cdd0621c18f0dc166f58c4e702c5

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

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

    bind_to Network

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

    def create(name:, ip_range:, subnets: nil, routes: nil, labels: {})
      prepare_request(
        'networks', j: COLLECT_ARGS.call(__method__, binding),
                    expected_code: 201
      ) do |response|
        Network.new(client, response.parsed_json[:network])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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