Class: MistApi::SwitchDhcpdConfigProperty

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

Overview

the Property key is the network name. In case of DHCP relay, it’s common for many networks to use the same dhcp relay, comma-separated network names can be used here (e.g. “net1,net2”)

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(dns_servers = SKIP, dns_suffix = SKIP, fixed_bindings = SKIP, gateway = SKIP, ip_end = SKIP, ip_end6 = SKIP, ip_start = SKIP, ip_start6 = SKIP, lease_time = 86400, options = SKIP, server_id_override = false, servers = SKIP, servers6 = SKIP, type = SKIP, type6 = SwitchDhcpdConfigTypeEnum::NONE, vendor_encapsulated = SKIP) ⇒ SwitchDhcpdConfigProperty

Returns a new instance of SwitchDhcpdConfigProperty.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 139

def initialize(dns_servers = SKIP, dns_suffix = SKIP, fixed_bindings = SKIP,
               gateway = SKIP, ip_end = SKIP, ip_end6 = SKIP,
               ip_start = SKIP, ip_start6 = SKIP, lease_time = 86400,
               options = SKIP, server_id_override = false, servers = SKIP,
               servers6 = SKIP, type = SKIP,
               type6 = SwitchDhcpdConfigTypeEnum::NONE,
               vendor_encapsulated = SKIP)
  @dns_servers = dns_servers unless dns_servers == SKIP
  @dns_suffix = dns_suffix unless dns_suffix == SKIP
  @fixed_bindings = fixed_bindings unless fixed_bindings == SKIP
  @gateway = gateway unless gateway == SKIP
  @ip_end = ip_end unless ip_end == SKIP
  @ip_end6 = ip_end6 unless ip_end6 == SKIP
  @ip_start = ip_start unless ip_start == SKIP
  @ip_start6 = ip_start6 unless ip_start6 == SKIP
  @lease_time = lease_time unless lease_time == SKIP
  @options = options unless options == SKIP
  @server_id_override = server_id_override unless server_id_override == SKIP
  @servers = servers unless servers == SKIP
  @servers6 = servers6 unless servers6 == SKIP
  @type = type unless type == SKIP
  @type6 = type6 unless type6 == SKIP
  @vendor_encapsulated = vendor_encapsulated unless vendor_encapsulated == SKIP
end

Instance Attribute Details

#dns_serversArray[String]

If ‘type`==`server` or `type6`==`server` - optional, if not defined, system one will be used

Returns:

  • (Array[String])


17
18
19
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 17

def dns_servers
  @dns_servers
end

#dns_suffixArray[String]

If ‘type`==`server` or `type6`==`server` - optional, if not defined, system one will be used

Returns:

  • (Array[String])


22
23
24
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 22

def dns_suffix
  @dns_suffix
end

#fixed_bindingsHash[String, DhcpdConfigFixedBinding]

If ‘type`==`server` or `type6`==`server`. Property key is the MAC Address. Format is `[0-9a-f]12` (e.g. “5684dae9ac8b”)

Returns:



27
28
29
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 27

def fixed_bindings
  @fixed_bindings
end

#gatewayString

If ‘type`==`server` - optional, `ip` will be used if not provided

Returns:

  • (String)


31
32
33
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 31

def gateway
  @gateway
end

#ip_endString

If ‘type`==`server`

Returns:

  • (String)


35
36
37
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 35

def ip_end
  @ip_end
end

#ip_end6String

If ‘type6`==`server`

Returns:

  • (String)


39
40
41
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 39

def ip_end6
  @ip_end6
end

#ip_startString

If ‘type`==`server`

Returns:

  • (String)


43
44
45
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 43

def ip_start
  @ip_start
end

#ip_start6String

If ‘type6`==`server`

Returns:

  • (String)


47
48
49
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 47

def ip_start6
  @ip_start6
end

#lease_timeInteger

In seconds, lease time has to be between 3600 [1hr] - 604800 [1 week], default is 86400 [1 day]

Returns:

  • (Integer)


52
53
54
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 52

def lease_time
  @lease_time
end

#optionsHash[String, DhcpdConfigOption]

If ‘type`==`server` or `type6`==`server`. Property key is the DHCP option number

Returns:



57
58
59
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 57

def options
  @options
end

#server_id_overrideTrueClass | FalseClass

‘server_id_override`==`true` means the device, when acts as DHCP relay and forwards DHCP responses from DHCP server to clients, should overwrite the Sever Identifier option (i.e. DHCP option 54) in DHCP responses with its own IP address.

Returns:

  • (TrueClass | FalseClass)


64
65
66
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 64

def server_id_override
  @server_id_override
end

#serversArray[String]

If ‘type`==`relay`

Returns:

  • (Array[String])


68
69
70
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 68

def servers
  @servers
end

#servers6Array[String]

If ‘type6`==`relay`

Returns:

  • (Array[String])


72
73
74
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 72

def servers6
  @servers6
end

#typeSwitchDhcpdConfigTypeEnum

enum: ‘none`, `relay` (DHCP Relay), `server` (DHCP Server)



76
77
78
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 76

def type
  @type
end

#type6SwitchDhcpdConfigTypeEnum

enum: ‘none`, `relay` (DHCP Relay), `server` (DHCP Server)



80
81
82
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 80

def type6
  @type6
end

#vendor_encapsulatedHash[String, DhcpdConfigVendorOption]

If ‘type`==`server` or `type6`==`server`. Property key is <enterprise number>:<sub option code>, with

* enterprise number: 1-65535

(www.iana.org/assignments/enterprise-numbers/enterprise-numbers)

* sub option code: 1-255, sub-option code'

Returns:



88
89
90
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 88

def vendor_encapsulated
  @vendor_encapsulated
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 165

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  dns_servers = hash.key?('dns_servers') ? hash['dns_servers'] : SKIP
  dns_suffix = hash.key?('dns_suffix') ? hash['dns_suffix'] : SKIP
  fixed_bindings = DhcpdConfigFixedBinding.from_hash(hash['fixed_bindings']) if
    hash['fixed_bindings']

  fixed_bindings = SKIP unless hash.key?('fixed_bindings')
  gateway = hash.key?('gateway') ? hash['gateway'] : SKIP
  ip_end = hash.key?('ip_end') ? hash['ip_end'] : SKIP
  ip_end6 = hash.key?('ip_end6') ? hash['ip_end6'] : SKIP
  ip_start = hash.key?('ip_start') ? hash['ip_start'] : SKIP
  ip_start6 = hash.key?('ip_start6') ? hash['ip_start6'] : SKIP
  lease_time = hash['lease_time'] ||= 86400
  options = DhcpdConfigOption.from_hash(hash['options']) if hash['options']

  options = SKIP unless hash.key?('options')
  server_id_override = hash['server_id_override'] ||= false
  servers = hash.key?('servers') ? hash['servers'] : SKIP
  servers6 = hash.key?('servers6') ? hash['servers6'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  type6 = hash['type6'] ||= SwitchDhcpdConfigTypeEnum::NONE
  vendor_encapsulated = DhcpdConfigVendorOption.from_hash(hash['vendor_encapsulated']) if
    hash['vendor_encapsulated']

  vendor_encapsulated = SKIP unless hash.key?('vendor_encapsulated')

  # Create object from extracted values.
  SwitchDhcpdConfigProperty.new(dns_servers,
                                dns_suffix,
                                fixed_bindings,
                                gateway,
                                ip_end,
                                ip_end6,
                                ip_start,
                                ip_start6,
                                lease_time,
                                options,
                                server_id_override,
                                servers,
                                servers6,
                                type,
                                type6,
                                vendor_encapsulated)
end

.namesObject

A mapping from model property names to API property names.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 91

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['dns_servers'] = 'dns_servers'
  @_hash['dns_suffix'] = 'dns_suffix'
  @_hash['fixed_bindings'] = 'fixed_bindings'
  @_hash['gateway'] = 'gateway'
  @_hash['ip_end'] = 'ip_end'
  @_hash['ip_end6'] = 'ip_end6'
  @_hash['ip_start'] = 'ip_start'
  @_hash['ip_start6'] = 'ip_start6'
  @_hash['lease_time'] = 'lease_time'
  @_hash['options'] = 'options'
  @_hash['server_id_override'] = 'server_id_override'
  @_hash['servers'] = 'servers'
  @_hash['servers6'] = 'servers6'
  @_hash['type'] = 'type'
  @_hash['type6'] = 'type6'
  @_hash['vendor_encapsulated'] = 'vendor_encapsulated'
  @_hash
end

.nullablesObject

An array for nullable fields



135
136
137
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 135

def self.nullables
  []
end

.optionalsObject

An array for optional fields



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 113

def self.optionals
  %w[
    dns_servers
    dns_suffix
    fixed_bindings
    gateway
    ip_end
    ip_end6
    ip_start
    ip_start6
    lease_time
    options
    server_id_override
    servers
    servers6
    type
    type6
    vendor_encapsulated
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



225
226
227
228
229
230
231
232
233
234
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 225

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} dns_servers: #{@dns_servers.inspect}, dns_suffix: #{@dns_suffix.inspect},"\
  " fixed_bindings: #{@fixed_bindings.inspect}, gateway: #{@gateway.inspect}, ip_end:"\
  " #{@ip_end.inspect}, ip_end6: #{@ip_end6.inspect}, ip_start: #{@ip_start.inspect},"\
  " ip_start6: #{@ip_start6.inspect}, lease_time: #{@lease_time.inspect}, options:"\
  " #{@options.inspect}, server_id_override: #{@server_id_override.inspect}, servers:"\
  " #{@servers.inspect}, servers6: #{@servers6.inspect}, type: #{@type.inspect}, type6:"\
  " #{@type6.inspect}, vendor_encapsulated: #{@vendor_encapsulated.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



214
215
216
217
218
219
220
221
222
# File 'lib/mist_api/models/switch_dhcpd_config_property.rb', line 214

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} dns_servers: #{@dns_servers}, dns_suffix: #{@dns_suffix}, fixed_bindings:"\
  " #{@fixed_bindings}, gateway: #{@gateway}, ip_end: #{@ip_end}, ip_end6: #{@ip_end6},"\
  " ip_start: #{@ip_start}, ip_start6: #{@ip_start6}, lease_time: #{@lease_time}, options:"\
  " #{@options}, server_id_override: #{@server_id_override}, servers: #{@servers}, servers6:"\
  " #{@servers6}, type: #{@type}, type6: #{@type6}, vendor_encapsulated:"\
  " #{@vendor_encapsulated}>"
end