Sha256: 1477645a3c636bbdca1dacc88765d44a4b18f7e5e94490219a19bf2e045e018b

Contents?: true

Size: 785 Bytes

Versions: 13

Compression:

Stored size: 785 Bytes

Contents

module Fog
  module Vsphere
    class Compute
      class Rules < Fog::Collection
        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

13 entries across 13 versions & 1 rubygems

Version Path
fog-vsphere-3.7.0 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.8 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.7 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.6 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.5 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.4 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.3 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.2 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.5.3 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.6.0 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.5.2 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.5.1 lib/fog/vsphere/models/compute/rules.rb
fog-vsphere-3.5.0 lib/fog/vsphere/models/compute/rules.rb