Class: MistApi::CaptureGateway

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

Overview

Initiate a Gateway (SSR/SRX) Packet Capture

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(gateways = nil, duration = 600, format = CaptureGatewayFormatEnum::STREAM, max_pkt_len = 512, num_packets = 1024, ports = SKIP) ⇒ CaptureGateway

Returns a new instance of CaptureGateway.



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/mist_api/models/capture_gateway.rb', line 74

def initialize(gateways = nil, duration = 600,
               format = CaptureGatewayFormatEnum::STREAM, max_pkt_len = 512,
               num_packets = 1024, ports = SKIP)
  @duration = duration unless duration == SKIP
  @format = format unless format == SKIP
  @gateways = gateways
  @max_pkt_len = max_pkt_len unless max_pkt_len == SKIP
  @num_packets = num_packets unless num_packets == SKIP
  @ports = ports unless ports == SKIP
  @type = 'gateway'
end

Instance Attribute Details

#durationInteger

Duration of the capture, in seconds

Returns:

  • (Integer)


14
15
16
# File 'lib/mist_api/models/capture_gateway.rb', line 14

def duration
  @duration
end

#formatCaptureGatewayFormatEnum

enum: ‘stream`



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

def format
  @format
end

#gatewaysHash[String, CaptureGatewayGateways]

List of SSRs. Property key is the SSR MAC

Returns:



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

def gateways
  @gateways
end

#max_pkt_lenInteger

minimum is 64 (SSR) / 68 (SRX) maximum is 10240 (SSR) / 1520 (SRX)

Returns:

  • (Integer)


26
27
28
# File 'lib/mist_api/models/capture_gateway.rb', line 26

def max_pkt_len
  @max_pkt_len
end

#num_packetsInteger

number of packets to capture, 0 for unlimited, default is 1024, maximum is 10000

Returns:

  • (Integer)


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

def num_packets
  @num_packets
end

#portsHash[String, CaptureGatewayGatewaysPort]

Property key is the port ID

Returns:



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

def ports
  @ports
end

#typeString (readonly)

enum: ‘gateway`

Returns:

  • (String)


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

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  gateways = CaptureGatewayGateways.from_hash(hash['gateways']) if hash['gateways']

  gateways = nil unless hash.key?('gateways')
  duration = hash['duration'] ||= 600
  format = hash['format'] ||= CaptureGatewayFormatEnum::STREAM
  max_pkt_len = hash['max_pkt_len'] ||= 512
  num_packets = hash['num_packets'] ||= 1024
  ports = CaptureGatewayGatewaysPort.from_hash(hash['ports']) if hash['ports']

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

  # Create object from extracted values.
  CaptureGateway.new(gateways,
                     duration,
                     format,
                     max_pkt_len,
                     num_packets,
                     ports)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mist_api/models/capture_gateway.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['duration'] = 'duration'
  @_hash['format'] = 'format'
  @_hash['gateways'] = 'gateways'
  @_hash['max_pkt_len'] = 'max_pkt_len'
  @_hash['num_packets'] = 'num_packets'
  @_hash['ports'] = 'ports'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



66
67
68
69
70
71
72
# File 'lib/mist_api/models/capture_gateway.rb', line 66

def self.nullables
  %w[
    duration
    max_pkt_len
    num_packets
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    duration
    format
    max_pkt_len
    num_packets
    ports
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



120
121
122
123
124
125
# File 'lib/mist_api/models/capture_gateway.rb', line 120

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} duration: #{@duration.inspect}, format: #{@format.inspect}, gateways:"\
  " #{@gateways.inspect}, max_pkt_len: #{@max_pkt_len.inspect}, num_packets:"\
  " #{@num_packets.inspect}, ports: #{@ports.inspect}, type: #{@type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



112
113
114
115
116
117
# File 'lib/mist_api/models/capture_gateway.rb', line 112

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} duration: #{@duration}, format: #{@format}, gateways: #{@gateways},"\
  " max_pkt_len: #{@max_pkt_len}, num_packets: #{@num_packets}, ports: #{@ports}, type:"\
  " #{@type}>"
end