Class: Puppet::ResourceApi::TransportSchemaDef

Inherits:
BaseTypeDefinition show all
Defined in:
lib/puppet_x/puppetlabs/cisco_ios/transport_shim.rb

Overview

RSAPI Transport schema

Instance Attribute Summary

Attributes inherited from BaseTypeDefinition

#attributes, #definition

Instance Method Summary collapse

Methods inherited from BaseTypeDefinition

#check_schema, #check_schema_keys, #check_schema_values, #name, #namevars, #validate_schema

Constructor Details

#initialize(definition) ⇒ TransportSchemaDef

Returns a new instance of TransportSchemaDef.



44
45
46
# File 'lib/puppet_x/puppetlabs/cisco_ios/transport_shim.rb', line 44

def initialize(definition)
  super(definition, :connection_info)
end

Instance Method Details

#notify_schema_errors(message) ⇒ Object



64
65
66
# File 'lib/puppet_x/puppetlabs/cisco_ios/transport_shim.rb', line 64

def notify_schema_errors(message)
  # do nothing to satisfy tasks
end

#validate(resource) ⇒ Object

Raises:

  • (Puppet::ResourceError)


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/puppet_x/puppetlabs/cisco_ios/transport_shim.rb', line 48

def validate(resource)
  # enforce mandatory attributes
  missing_attrs = []

  attributes.each do |name, _options|
    type = @data_type_cache[attributes[name][:type]]

    if resource[name].nil? && !(type.instance_of? Puppet::Pops::Types::POptionalType)
      missing_attrs << name
    end
  end

  error_msg = "The following mandatory attributes were not provided:\n    *  " + missing_attrs.join(", \n    *  ")
  raise Puppet::ResourceError, error_msg if missing_attrs.any?
end