Class: MistApi::SwitchNetwork

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

Overview

A network represents a network segment. It can either represent a VLAN (then usually ties to a L3 subnet), optionally associate it with a subnet which can later be used to create addition routes. Used for ports doing ‘family ethernet-switching`. It can also be a pure L3-subnet that can then be used against a port that with `family inet`.

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(vlan_id = nil, gateway = SKIP, gateway6 = SKIP, isolation = false, isolation_vlan_id = SKIP, subnet = SKIP, subnet6 = SKIP) ⇒ SwitchNetwork

Returns a new instance of SwitchNetwork.



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/mist_api/models/switch_network.rb', line 82

def initialize(vlan_id = nil, gateway = SKIP, gateway6 = SKIP,
               isolation = false, isolation_vlan_id = SKIP, subnet = SKIP,
               subnet6 = SKIP)
  @gateway = gateway unless gateway == SKIP
  @gateway6 = gateway6 unless gateway6 == SKIP
  @isolation = isolation unless isolation == SKIP
  @isolation_vlan_id = isolation_vlan_id unless isolation_vlan_id == SKIP
  @subnet = subnet unless subnet == SKIP
  @subnet6 = subnet6 unless subnet6 == SKIP
  @vlan_id = vlan_id
end

Instance Attribute Details

#gatewayString

Only required for EVPN-VXLAN networks, IPv4 Virtual Gateway

Returns:

  • (String)


18
19
20
# File 'lib/mist_api/models/switch_network.rb', line 18

def gateway
  @gateway
end

#gateway6String

Only required for EVPN-VXLAN networks, IPv6 Virtual Gateway

Returns:

  • (String)


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

def gateway6
  @gateway6
end

#isolationTrueClass | FalseClass

whether to stop clients to talk to each other, default is false (when enabled, a unique isolation_vlan_id is required). NOTE: this features requires uplink device to also a be Juniper device and ‘inter_switch_link` to be set. See also `inter_isolation_network_link` and `community_vlan_id` in port_usage

Returns:

  • (TrueClass | FalseClass)


30
31
32
# File 'lib/mist_api/models/switch_network.rb', line 30

def isolation
  @isolation
end

#isolation_vlan_idString

whether to stop clients to talk to each other, default is false (when enabled, a unique isolation_vlan_id is required). NOTE: this features requires uplink device to also a be Juniper device and ‘inter_switch_link` to be set. See also `inter_isolation_network_link` and `community_vlan_id` in port_usage

Returns:

  • (String)


38
39
40
# File 'lib/mist_api/models/switch_network.rb', line 38

def isolation_vlan_id
  @isolation_vlan_id
end

#subnetString

Optional for pure switching, required when L3 / routing features are used

Returns:

  • (String)


42
43
44
# File 'lib/mist_api/models/switch_network.rb', line 42

def subnet
  @subnet
end

#subnet6String

Optional for pure switching, required when L3 / routing features are used

Returns:

  • (String)


46
47
48
# File 'lib/mist_api/models/switch_network.rb', line 46

def subnet6
  @subnet6
end

#vlan_idObject

Optional for pure switching, required when L3 / routing features are used

Returns:

  • (Object)


50
51
52
# File 'lib/mist_api/models/switch_network.rb', line 50

def vlan_id
  @vlan_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/mist_api/models/switch_network.rb', line 95

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  vlan_id = hash.key?('vlan_id') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:VlanIdWithVariable7), hash['vlan_id']
  ) : nil
  gateway = hash.key?('gateway') ? hash['gateway'] : SKIP
  gateway6 = hash.key?('gateway6') ? hash['gateway6'] : SKIP
  isolation = hash['isolation'] ||= false
  isolation_vlan_id =
    hash.key?('isolation_vlan_id') ? hash['isolation_vlan_id'] : SKIP
  subnet = hash.key?('subnet') ? hash['subnet'] : SKIP
  subnet6 = hash.key?('subnet6') ? hash['subnet6'] : SKIP

  # Create object from extracted values.
  SwitchNetwork.new(vlan_id,
                    gateway,
                    gateway6,
                    isolation,
                    isolation_vlan_id,
                    subnet,
                    subnet6)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/mist_api/models/switch_network.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['gateway'] = 'gateway'
  @_hash['gateway6'] = 'gateway6'
  @_hash['isolation'] = 'isolation'
  @_hash['isolation_vlan_id'] = 'isolation_vlan_id'
  @_hash['subnet'] = 'subnet'
  @_hash['subnet6'] = 'subnet6'
  @_hash['vlan_id'] = 'vlan_id'
  @_hash
end

.nullablesObject

An array for nullable fields



78
79
80
# File 'lib/mist_api/models/switch_network.rb', line 78

def self.nullables
  []
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
72
73
74
75
# File 'lib/mist_api/models/switch_network.rb', line 66

def self.optionals
  %w[
    gateway
    gateway6
    isolation
    isolation_vlan_id
    subnet
    subnet6
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (SwitchNetwork | Hash)

    value against the validation is performed.



122
123
124
125
126
127
128
129
130
131
132
# File 'lib/mist_api/models/switch_network.rb', line 122

def self.validate(value)
  if value.instance_of? self
    return UnionTypeLookUp.get(:VlanIdWithVariable7)
                          .validate(value.vlan_id)
  end

  return false unless value.instance_of? Hash

  UnionTypeLookUp.get(:VlanIdWithVariable7)
                 .validate(value['vlan_id'])
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



143
144
145
146
147
148
# File 'lib/mist_api/models/switch_network.rb', line 143

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} gateway: #{@gateway.inspect}, gateway6: #{@gateway6.inspect}, isolation:"\
  " #{@isolation.inspect}, isolation_vlan_id: #{@isolation_vlan_id.inspect}, subnet:"\
  " #{@subnet.inspect}, subnet6: #{@subnet6.inspect}, vlan_id: #{@vlan_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



135
136
137
138
139
140
# File 'lib/mist_api/models/switch_network.rb', line 135

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} gateway: #{@gateway}, gateway6: #{@gateway6}, isolation: #{@isolation},"\
  " isolation_vlan_id: #{@isolation_vlan_id}, subnet: #{@subnet}, subnet6: #{@subnet6},"\
  " vlan_id: #{@vlan_id}>"
end