Class: OCI::Logging::Models::UnifiedAgentParser

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/logging/models/unified_agent_parser.rb

Overview

Source parser object. This class has direct subclasses. If you are using this class as input to a service operations then you should favor using a subclass over the base class

Constant Summary collapse

PARSER_TYPE_ENUM =
[
  PARSER_TYPE_AUDITD = 'AUDITD'.freeze,
  PARSER_TYPE_CRI = 'CRI'.freeze,
  PARSER_TYPE_JSON = 'JSON'.freeze,
  PARSER_TYPE_TSV = 'TSV'.freeze,
  PARSER_TYPE_CSV = 'CSV'.freeze,
  PARSER_TYPE_NONE = 'NONE'.freeze,
  PARSER_TYPE_SYSLOG = 'SYSLOG'.freeze,
  PARSER_TYPE_APACHE2 = 'APACHE2'.freeze,
  PARSER_TYPE_APACHE_ERROR = 'APACHE_ERROR'.freeze,
  PARSER_TYPE_MSGPACK = 'MSGPACK'.freeze,
  PARSER_TYPE_REGEXP = 'REGEXP'.freeze,
  PARSER_TYPE_MULTILINE = 'MULTILINE'.freeze,
  PARSER_TYPE_GROK = 'GROK'.freeze,
  PARSER_TYPE_MULTILINE_GROK = 'MULTILINE_GROK'.freeze,
  PARSER_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UnifiedAgentParser

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):

  • :parser_type (String)

    The value to assign to the #parser_type property

  • :field_time_key (String)

    The value to assign to the #field_time_key property

  • :types (Hash<String, String>)

    The value to assign to the #types property

  • :null_value_pattern (String)

    The value to assign to the #null_value_pattern property

  • :is_null_empty_string (BOOLEAN)

    The value to assign to the #is_null_empty_string property

  • :is_estimate_current_event (BOOLEAN)

    The value to assign to the #is_estimate_current_event property

  • :is_keep_time_key (BOOLEAN)

    The value to assign to the #is_keep_time_key property

  • :timeout_in_milliseconds (Integer)

    The value to assign to the #timeout_in_milliseconds property



158
159
160
161
162
163
164
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
212
213
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 158

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.parser_type = attributes[:'parserType'] if attributes[:'parserType']

  raise 'You cannot provide both :parserType and :parser_type' if attributes.key?(:'parserType') && attributes.key?(:'parser_type')

  self.parser_type = attributes[:'parser_type'] if attributes[:'parser_type']

  self.field_time_key = attributes[:'fieldTimeKey'] if attributes[:'fieldTimeKey']

  raise 'You cannot provide both :fieldTimeKey and :field_time_key' if attributes.key?(:'fieldTimeKey') && attributes.key?(:'field_time_key')

  self.field_time_key = attributes[:'field_time_key'] if attributes[:'field_time_key']

  self.types = attributes[:'types'] if attributes[:'types']

  self.null_value_pattern = attributes[:'nullValuePattern'] if attributes[:'nullValuePattern']

  raise 'You cannot provide both :nullValuePattern and :null_value_pattern' if attributes.key?(:'nullValuePattern') && attributes.key?(:'null_value_pattern')

  self.null_value_pattern = attributes[:'null_value_pattern'] if attributes[:'null_value_pattern']

  self.is_null_empty_string = attributes[:'isNullEmptyString'] unless attributes[:'isNullEmptyString'].nil?
  self.is_null_empty_string = false if is_null_empty_string.nil? && !attributes.key?(:'isNullEmptyString') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isNullEmptyString and :is_null_empty_string' if attributes.key?(:'isNullEmptyString') && attributes.key?(:'is_null_empty_string')

  self.is_null_empty_string = attributes[:'is_null_empty_string'] unless attributes[:'is_null_empty_string'].nil?
  self.is_null_empty_string = false if is_null_empty_string.nil? && !attributes.key?(:'isNullEmptyString') && !attributes.key?(:'is_null_empty_string') # rubocop:disable Style/StringLiterals

  self.is_estimate_current_event = attributes[:'isEstimateCurrentEvent'] unless attributes[:'isEstimateCurrentEvent'].nil?
  self.is_estimate_current_event = true if is_estimate_current_event.nil? && !attributes.key?(:'isEstimateCurrentEvent') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isEstimateCurrentEvent and :is_estimate_current_event' if attributes.key?(:'isEstimateCurrentEvent') && attributes.key?(:'is_estimate_current_event')

  self.is_estimate_current_event = attributes[:'is_estimate_current_event'] unless attributes[:'is_estimate_current_event'].nil?
  self.is_estimate_current_event = true if is_estimate_current_event.nil? && !attributes.key?(:'isEstimateCurrentEvent') && !attributes.key?(:'is_estimate_current_event') # rubocop:disable Style/StringLiterals

  self.is_keep_time_key = attributes[:'isKeepTimeKey'] unless attributes[:'isKeepTimeKey'].nil?
  self.is_keep_time_key = false if is_keep_time_key.nil? && !attributes.key?(:'isKeepTimeKey') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isKeepTimeKey and :is_keep_time_key' if attributes.key?(:'isKeepTimeKey') && attributes.key?(:'is_keep_time_key')

  self.is_keep_time_key = attributes[:'is_keep_time_key'] unless attributes[:'is_keep_time_key'].nil?
  self.is_keep_time_key = false if is_keep_time_key.nil? && !attributes.key?(:'isKeepTimeKey') && !attributes.key?(:'is_keep_time_key') # rubocop:disable Style/StringLiterals

  self.timeout_in_milliseconds = attributes[:'timeoutInMilliseconds'] if attributes[:'timeoutInMilliseconds']

  raise 'You cannot provide both :timeoutInMilliseconds and :timeout_in_milliseconds' if attributes.key?(:'timeoutInMilliseconds') && attributes.key?(:'timeout_in_milliseconds')

  self.timeout_in_milliseconds = attributes[:'timeout_in_milliseconds'] if attributes[:'timeout_in_milliseconds']
end

Instance Attribute Details

#field_time_keyString

Specifies the time field for the event time. If the event doesn't have this field, the current time is used.

Returns:

  • (String)


37
38
39
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 37

def field_time_key
  @field_time_key
end

#is_estimate_current_eventBOOLEAN

If true, use Fluent::EventTime.now(current time) as a timestamp when the time_key is specified.

Returns:

  • (BOOLEAN)


74
75
76
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 74

def is_estimate_current_event
  @is_estimate_current_event
end

#is_keep_time_keyBOOLEAN

If true, keep the time field in the record.

Returns:

  • (BOOLEAN)


78
79
80
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 78

def is_keep_time_key
  @is_keep_time_key
end

#is_null_empty_stringBOOLEAN

If true, an empty string field is replaced with a null value.

Returns:

  • (BOOLEAN)


70
71
72
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 70

def is_null_empty_string
  @is_null_empty_string
end

#null_value_patternString

Specify the null value pattern.

Returns:

  • (String)


66
67
68
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 66

def null_value_pattern
  @null_value_pattern
end

#parser_typeString

[Required] Type of fluent parser.

Returns:

  • (String)


33
34
35
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 33

def parser_type
  @parser_type
end

#timeout_in_millisecondsInteger

Specify the timeout for parse processing. This is mainly for detecting an incorrect regexp pattern.

Returns:

  • (Integer)


82
83
84
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 82

def timeout_in_milliseconds
  @timeout_in_milliseconds
end

#typesHash<String, String>

Specify types for converting a field into another type. For example, With this configuration: <parse> @type csv keys time,host,req_id,user time_key time </parse>

This incoming event: "2013/02/28 12:00:00,192.168.0.1,111,-"

is parsed as: 1362020400 (2013/02/28/ 12:00:00)

record:
{
  \"host\"   : \"192.168.0.1\",
  \"req_id\" : \"111\",
  \"user\"   : \"-\"
}

Returns:

  • (Hash<String, String>)


62
63
64
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 62

def types
  @types
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 85

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'parser_type': :'parserType',
    'field_time_key': :'fieldTimeKey',
    'types': :'types',
    'null_value_pattern': :'nullValuePattern',
    'is_null_empty_string': :'isNullEmptyString',
    'is_estimate_current_event': :'isEstimateCurrentEvent',
    'is_keep_time_key': :'isKeepTimeKey',
    'timeout_in_milliseconds': :'timeoutInMilliseconds'
    # rubocop:enable Style/SymbolLiteral
  }
end

.get_subtype(object_hash) ⇒ Object

Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 121

def self.get_subtype(object_hash)
  type = object_hash[:'parserType'] # rubocop:disable Style/SymbolLiteral

  return 'OCI::Logging::Models::UnifiedAgentMultilineGrokParser' if type == 'MULTILINE_GROK'
  return 'OCI::Logging::Models::UnifiedJSONParser' if type == 'JSON'
  return 'OCI::Logging::Models::UnifiedAgentGrokParser' if type == 'GROK'
  return 'OCI::Logging::Models::UnifiedAgentNoneParser' if type == 'NONE'
  return 'OCI::Logging::Models::UnifiedAgentSyslogParser' if type == 'SYSLOG'
  return 'OCI::Logging::Models::UnifiedAgentAuditdParser' if type == 'AUDITD'
  return 'OCI::Logging::Models::UnifiedAgentApache2Parser' if type == 'APACHE2'
  return 'OCI::Logging::Models::UnifiedAgentRegexParser' if type == 'REGEXP'
  return 'OCI::Logging::Models::UnifiedAgentMultilineParser' if type == 'MULTILINE'
  return 'OCI::Logging::Models::UnifiedAgentTsvParser' if type == 'TSV'
  return 'OCI::Logging::Models::UnifiedAgentCriParser' if type == 'CRI'
  return 'OCI::Logging::Models::UnifiedAgentApacheErrorParser' if type == 'APACHE_ERROR'
  return 'OCI::Logging::Models::UnifiedAgentMsgpackParser' if type == 'MSGPACK'
  return 'OCI::Logging::Models::UnifiedAgentCsvParser' if type == 'CSV'

  # TODO: Log a warning when the subtype is not found.
  'OCI::Logging::Models::UnifiedAgentParser'
end

.swagger_typesObject

Attribute type mapping.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 101

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'parser_type': :'String',
    'field_time_key': :'String',
    'types': :'Hash<String, String>',
    'null_value_pattern': :'String',
    'is_null_empty_string': :'BOOLEAN',
    'is_estimate_current_event': :'BOOLEAN',
    'is_keep_time_key': :'BOOLEAN',
    'timeout_in_milliseconds': :'Integer'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 235

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    parser_type == other.parser_type &&
    field_time_key == other.field_time_key &&
    types == other.types &&
    null_value_pattern == other.null_value_pattern &&
    is_null_empty_string == other.is_null_empty_string &&
    is_estimate_current_event == other.is_estimate_current_event &&
    is_keep_time_key == other.is_keep_time_key &&
    timeout_in_milliseconds == other.timeout_in_milliseconds
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 272

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


252
253
254
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 252

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



261
262
263
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 261

def hash
  [parser_type, field_time_key, types, null_value_pattern, is_null_empty_string, is_estimate_current_event, is_keep_time_key, timeout_in_milliseconds].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



305
306
307
308
309
310
311
312
313
314
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 305

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



299
300
301
# File 'lib/oci/logging/models/unified_agent_parser.rb', line 299

def to_s
  to_hash.to_s
end