Class: Puppet::ResourceApi::TransportSchemaDef

Inherits:
BaseTypeDefinition show all
Defined in:
lib/puppet/resource_api/type_definition.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, #insyncable_attributes, #name, #namevars, #validate_schema

Constructor Details

#initialize(definition) ⇒ TransportSchemaDef

Returns a new instance of TransportSchemaDef.



93
94
95
# File 'lib/puppet/resource_api/type_definition.rb', line 93

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

Instance Method Details

#notify_schema_errors(message) ⇒ Object

Raises:

  • (Puppet::DevError)


113
114
115
# File 'lib/puppet/resource_api/type_definition.rb', line 113

def notify_schema_errors(message)
  raise Puppet::DevError, message
end

#validate(resource) ⇒ Object

Raises:

  • (Puppet::ResourceError)


97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/puppet/resource_api/type_definition.rb', line 97

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