Sha256: 03f16e102e9bd5c7cc0076f60f95ddb6a45841b74e36b73da28380eae064db65

Contents?: true

Size: 848 Bytes

Versions: 10

Compression:

Stored size: 848 Bytes

Contents

module Fog
  module Vsphere
    class Compute
      class Rules < Fog::Collection
        autoload :Rule, File.expand_path('../rule', __FILE__)

        model Fog::Vsphere::Compute::Rule
        attribute :datacenter
        attribute :cluster

        def all(_filters = {})
          requires :datacenter, :cluster
          load service.list_rules(datacenter: datacenter, cluster: cluster)
        end

        def get(key_or_name)
          all.find { |rule| [rule.key, rule.name].include? key_or_name } ||
            raise(Fog::Vsphere::Compute::NotFound, "no such rule #{key_or_name}")
        end

        # Pass datacenter/cluster to every new rule
        def new(attributes = {})
          requires :datacenter, :cluster
          super(attributes.merge(datacenter: datacenter, cluster: cluster))
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-vsphere-3.4.0 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.3.1 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.3.0 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.2.5 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.2.2 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.2.1 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.2.0 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.1.1 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.1.0 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.0.0 lib/fog/vsphere/models/compute/rules.rb