Class: MistApi::SwitchOspfConfig

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/switch_ospf_config.rb

Overview

SwitchOspfConfig Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(areas = SKIP, enabled = false, export_policy = SKIP, import_policy = SKIP, reference_bandwidth = SKIP, additional_properties = nil) ⇒ SwitchOspfConfig

Returns a new instance of SwitchOspfConfig.



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/mist_api/models/switch_ospf_config.rb', line 62

def initialize(areas = SKIP, enabled = false, export_policy = SKIP,
               import_policy = SKIP, reference_bandwidth = SKIP,
               additional_properties = nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @areas = areas unless areas == SKIP
  @enabled = enabled unless enabled == SKIP
  @export_policy = export_policy unless export_policy == SKIP
  @import_policy = import_policy unless import_policy == SKIP
  @reference_bandwidth = reference_bandwidth unless reference_bandwidth == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#areasHash[String, SwitchOspfConfigArea]

Property key is the area name. Defines the OSPF areas configured on the switch.

Returns:



15
16
17
# File 'lib/mist_api/models/switch_ospf_config.rb', line 15

def areas
  @areas
end

#enabledTrueClass | FalseClass

Enable OSPF on the switch

Returns:

  • (TrueClass | FalseClass)


19
20
21
# File 'lib/mist_api/models/switch_ospf_config.rb', line 19

def enabled
  @enabled
end

#export_policyString

optional, for basic scenario, ‘import_policy` can be specified and can be applied to all networks in all areas if not explicitly specified

Returns:

  • (String)


24
25
26
# File 'lib/mist_api/models/switch_ospf_config.rb', line 24

def export_policy
  @export_policy
end

#import_policyString

optional, for basic scenario, ‘import_policy` can be specified and can be applied to all networks in all areas if not explicitly specified

Returns:

  • (String)


29
30
31
# File 'lib/mist_api/models/switch_ospf_config.rb', line 29

def import_policy
  @import_policy
end

#reference_bandwidthObject

Reference bandwidth. Integer(100000) or String (10g)

Returns:

  • (Object)


33
34
35
# File 'lib/mist_api/models/switch_ospf_config.rb', line 33

def reference_bandwidth
  @reference_bandwidth
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/mist_api/models/switch_ospf_config.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  areas = SwitchOspfConfigArea.from_hash(hash['areas']) if hash['areas']

  areas = SKIP unless hash.key?('areas')
  enabled = hash['enabled'] ||= false
  export_policy = hash.key?('export_policy') ? hash['export_policy'] : SKIP
  import_policy = hash.key?('import_policy') ? hash['import_policy'] : SKIP
  reference_bandwidth = hash.key?('reference_bandwidth') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:SwitchOspfConfigReferenceBandwidth), hash['reference_bandwidth']
  ) : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  SwitchOspfConfig.new(areas,
                       enabled,
                       export_policy,
                       import_policy,
                       reference_bandwidth,
                       additional_properties)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
# File 'lib/mist_api/models/switch_ospf_config.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['areas'] = 'areas'
  @_hash['enabled'] = 'enabled'
  @_hash['export_policy'] = 'export_policy'
  @_hash['import_policy'] = 'import_policy'
  @_hash['reference_bandwidth'] = 'reference_bandwidth'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/mist_api/models/switch_ospf_config.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



47
48
49
50
51
52
53
54
55
# File 'lib/mist_api/models/switch_ospf_config.rb', line 47

def self.optionals
  %w[
    areas
    enabled
    export_policy
    import_policy
    reference_bandwidth
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



109
110
111
112
113
114
115
# File 'lib/mist_api/models/switch_ospf_config.rb', line 109

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



126
127
128
129
130
131
# File 'lib/mist_api/models/switch_ospf_config.rb', line 126

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} areas: #{@areas.inspect}, enabled: #{@enabled.inspect}, export_policy:"\
  " #{@export_policy.inspect}, import_policy: #{@import_policy.inspect}, reference_bandwidth:"\
  " #{@reference_bandwidth.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



118
119
120
121
122
123
# File 'lib/mist_api/models/switch_ospf_config.rb', line 118

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} areas: #{@areas}, enabled: #{@enabled}, export_policy: #{@export_policy},"\
  " import_policy: #{@import_policy}, reference_bandwidth: #{@reference_bandwidth},"\
  " additional_properties: #{@additional_properties}>"
end