Class: MistApi::SwitchMatchingRule

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

Overview

Property key defines the type of matching, value is the string to match. e.g: * ‘match_name`: switch name must match the first 3 letters of the property value * `match_name`: switch name must match the property value from the 2nd to the 6th letter * `match_model`: switch model must match the first 8 letters of the property value * `match_role`: switch role must match the property value

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(additional_config_cmds = SKIP, default_port_usage = 'default', ip_config = SKIP, name = SKIP, oob_ip_config = SKIP, port_config = SKIP, port_mirroring = SKIP, stp_config = SKIP, switch_mgmt = SKIP, additional_properties = nil) ⇒ SwitchMatchingRule

Returns a new instance of SwitchMatchingRule.



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

def initialize(additional_config_cmds = SKIP,
               default_port_usage = 'default', ip_config = SKIP,
               name = SKIP, oob_ip_config = SKIP, port_config = SKIP,
               port_mirroring = SKIP, stp_config = SKIP, switch_mgmt = SKIP,
               additional_properties = nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @additional_config_cmds = additional_config_cmds unless additional_config_cmds == SKIP
  @default_port_usage = default_port_usage unless default_port_usage == SKIP
  @ip_config = ip_config unless ip_config == SKIP
  @name = name unless name == SKIP
  @oob_ip_config = oob_ip_config unless oob_ip_config == SKIP
  @port_config = port_config unless port_config == SKIP
  @port_mirroring = port_mirroring unless port_mirroring == SKIP
  @stp_config = stp_config unless stp_config == SKIP
  @switch_mgmt = switch_mgmt unless switch_mgmt == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_config_cmdsArray[String]

additional CLI commands to append to the generated Junos config. Note: no check is done

Returns:

  • (Array[String])


20
21
22
# File 'lib/mist_api/models/switch_matching_rule.rb', line 20

def additional_config_cmds
  @additional_config_cmds
end

#default_port_usageString

Port usage to assign to switch ports without any port usage assigned. Default: ‘default` to preserve default behavior

Returns:

  • (String)


25
26
27
# File 'lib/mist_api/models/switch_matching_rule.rb', line 25

def default_port_usage
  @default_port_usage
end

#ip_configSwitchMatchingRuleIpConfig

In-Band Management interface configuration



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

def ip_config
  @ip_config
end

#nameString

Rule name. WARNING: the name ‘default` is reserved and can only be used for the last rule in the list

Returns:

  • (String)


34
35
36
# File 'lib/mist_api/models/switch_matching_rule.rb', line 34

def name
  @name
end

#oob_ip_configSwitchMatchingRuleOobIpConfig

Out-of-Band Management interface configuration



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

def oob_ip_config
  @oob_ip_config
end

#port_configHash[String, JunosPortConfig]

Property key is the port name or range (e.g. “ge-0/0/0-10”)

Returns:



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

def port_config
  @port_config
end

#port_mirroringHash[String, SwitchPortMirroringProperty]

Property key is the port mirroring instance name. ‘port_mirroring` can be added under device/site settings. It takes interface and ports as input for ingress, interface as input for egress and can take interface and port as output. A maximum 4 mirroring ports is allowed

Returns:



49
50
51
# File 'lib/mist_api/models/switch_matching_rule.rb', line 49

def port_mirroring
  @port_mirroring
end

#stp_configSwitchStpConfig

Property key is the port mirroring instance name. ‘port_mirroring` can be added under device/site settings. It takes interface and ports as input for ingress, interface as input for egress and can take interface and port as output. A maximum 4 mirroring ports is allowed

Returns:



56
57
58
# File 'lib/mist_api/models/switch_matching_rule.rb', line 56

def stp_config
  @stp_config
end

#switch_mgmtSwitchMgmt

Switch Management settings

Returns:



60
61
62
# File 'lib/mist_api/models/switch_matching_rule.rb', line 60

def switch_mgmt
  @switch_mgmt
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/mist_api/models/switch_matching_rule.rb', line 118

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  additional_config_cmds =
    hash.key?('additional_config_cmds') ? hash['additional_config_cmds'] : SKIP
  default_port_usage = hash['default_port_usage'] ||= 'default'
  ip_config = SwitchMatchingRuleIpConfig.from_hash(hash['ip_config']) if hash['ip_config']
  name = hash.key?('name') ? hash['name'] : SKIP
  oob_ip_config = SwitchMatchingRuleOobIpConfig.from_hash(hash['oob_ip_config']) if
    hash['oob_ip_config']
  port_config = JunosPortConfig.from_hash(hash['port_config']) if hash['port_config']

  port_config = SKIP unless hash.key?('port_config')
  port_mirroring = SwitchPortMirroringProperty.from_hash(hash['port_mirroring']) if
    hash['port_mirroring']

  port_mirroring = SKIP unless hash.key?('port_mirroring')
  stp_config = SwitchStpConfig.from_hash(hash['stp_config']) if hash['stp_config']
  switch_mgmt = SwitchMgmt.from_hash(hash['switch_mgmt']) if hash['switch_mgmt']

  # 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| String(value) }
  )

  # Create object from extracted values.
  SwitchMatchingRule.new(additional_config_cmds,
                         default_port_usage,
                         ip_config,
                         name,
                         oob_ip_config,
                         port_config,
                         port_mirroring,
                         stp_config,
                         switch_mgmt,
                         additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['additional_config_cmds'] = 'additional_config_cmds'
  @_hash['default_port_usage'] = 'default_port_usage'
  @_hash['ip_config'] = 'ip_config'
  @_hash['name'] = 'name'
  @_hash['oob_ip_config'] = 'oob_ip_config'
  @_hash['port_config'] = 'port_config'
  @_hash['port_mirroring'] = 'port_mirroring'
  @_hash['stp_config'] = 'stp_config'
  @_hash['switch_mgmt'] = 'switch_mgmt'
  @_hash
end

.nullablesObject

An array for nullable fields



93
94
95
# File 'lib/mist_api/models/switch_matching_rule.rb', line 93

def self.nullables
  []
end

.optionalsObject

An array for optional fields



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/mist_api/models/switch_matching_rule.rb', line 78

def self.optionals
  %w[
    additional_config_cmds
    default_port_usage
    ip_config
    name
    oob_ip_config
    port_config
    port_mirroring
    stp_config
    switch_mgmt
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



170
171
172
173
174
175
176
177
178
# File 'lib/mist_api/models/switch_matching_rule.rb', line 170

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} additional_config_cmds: #{@additional_config_cmds.inspect},"\
  " default_port_usage: #{@default_port_usage.inspect}, ip_config: #{@ip_config.inspect},"\
  " name: #{@name.inspect}, oob_ip_config: #{@oob_ip_config.inspect}, port_config:"\
  " #{@port_config.inspect}, port_mirroring: #{@port_mirroring.inspect}, stp_config:"\
  " #{@stp_config.inspect}, switch_mgmt: #{@switch_mgmt.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



160
161
162
163
164
165
166
167
# File 'lib/mist_api/models/switch_matching_rule.rb', line 160

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} additional_config_cmds: #{@additional_config_cmds}, default_port_usage:"\
  " #{@default_port_usage}, ip_config: #{@ip_config}, name: #{@name}, oob_ip_config:"\
  " #{@oob_ip_config}, port_config: #{@port_config}, port_mirroring: #{@port_mirroring},"\
  " stp_config: #{@stp_config}, switch_mgmt: #{@switch_mgmt}, additional_properties:"\
  " #{@additional_properties}>"
end