Class: PuppetX::Puppetlabs::Swagger::Provider
- Defined in:
- lib/puppet_x/puppetlabs/swagger/provider.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.instances ⇒ Object
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 |
.prefetch(resources) ⇒ Object
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 |
.read_only(*methods) ⇒ Object
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
#exists? ⇒ 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 |