Class: PuppetX::Puppetlabs::Swagger::Provider

Inherits:
Puppet::Provider
  • Object
show all
Defined in:
lib/puppet_x/puppetlabs/swagger/provider.rb

Direct Known Subclasses

Kubernetes::Provider

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

Method: PuppetX::Puppetlabs::Swagger::Provider.instances

Defined in:
lib/puppet_x/puppetlabs/swagger/provider.rb

+ (Object) instances



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/puppet_x/puppetlabs/swagger/provider.rb', line 15

def self.instances
  begin
    list_instances.collect do |instance|
      begin
        hash = instance_to_hash(instance)
        Puppet.debug("Ignoring #{name} due to invalid or incomplete response") unless hash
        new(hash) if hash
      end
    end.compact
  rescue Timeout::Error, StandardError => e
    raise PuppetX::Puppetlabs::Swagger::PrefetchError.new(self.resource_type.name.to_s, e)
  end
end

Method: PuppetX::Puppetlabs::Swagger::Provider.prefetch

Defined in:
lib/puppet_x/puppetlabs/swagger/provider.rb

+ (Object) prefetch(resources)



29
30
31
32
33
34
35
# File 'lib/puppet_x/puppetlabs/swagger/provider.rb', line 29

def self.prefetch(resources)
  instances.each do |prov|
    if resource = resources[prov.name] # rubocop:disable Lint/AssignmentInCondition
      resource.provider = prov
    end
  end
end

Method: PuppetX::Puppetlabs::Swagger::Provider.read_only

Defined in:
lib/puppet_x/puppetlabs/swagger/provider.rb

+ (Object) read_only(*methods)



7
8
9
10
11
12
13
# File 'lib/puppet_x/puppetlabs/swagger/provider.rb', line 7

def self.read_only(*methods)
  methods.each do |method|
    define_method("#{method}=") do |v|
      fail "#{method} property is read-only once #{resource.type} created."
    end
  end
end

Instance Method Details

Method: PuppetX::Puppetlabs::Swagger::Provider#exists?

Defined in:
lib/puppet_x/puppetlabs/swagger/provider.rb

- (Boolean) exists?

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/puppet_x/puppetlabs/swagger/provider.rb', line 37

def exists?
  Puppet.info("Checking if #{name} exists")
  @property_hash[:ensure] and @property_hash[:ensure] != :absent
end