Sha256: 33800c2ac17a1d9136548554ef9b74263790c6d2916a096bdd2c7f68cabfe867

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

# frozen_string_literal: true

module Hcloud
  class FirewallResource < 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:, rules: [], apply_to: [], labels: {})
      prepare_request(
        'firewalls', j: COLLECT_ARGS.call(__method__, binding),
                     expected_code: 201
      ) do |response|
        Firewall.new(client, response.parsed_json[:firewall])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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