Class: LogStash::Inputs::AkamaiSiem::Request

Inherits:
Struct
  • Object
show all
Extended by:
MiddlewareRegistry
Defined in:
lib/logstash/inputs/akamai_siem/request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MiddlewareRegistry

lookup_middleware, register_middleware, registered_middleware, unregister_middleware

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



4
5
6
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 4

def body
  @body
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



4
5
6
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 4

def headers
  @headers
end

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



4
5
6
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 4

def host
  @host
end

#http_methodObject

Returns the value of attribute http_method

Returns:

  • (Object)

    the current value of http_method



4
5
6
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 4

def http_method
  @http_method
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 4

def path
  @path
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



4
5
6
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 4

def url
  @url
end

Class Method Details

.create(request_method) {|request| ... } ⇒ Request

Parameters:

  • request_method (String)

Yields:

  • (request)

    for block customization, if block given

Yield Parameters:

Returns:



15
16
17
18
19
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 15

def self.create(request_method)
  new(request_method).tap do |request|
    yield(request) if block_given?
  end
end

Instance Method Details

#[](key) ⇒ Object

Returns value of the given header name.

Parameters:

  • key (Object)

    key to look up in headers

Returns:

  • (Object)

    value of the given header name



50
51
52
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 50

def [](key)
  headers[key]
end

#[]=(key, value) ⇒ Object

Parameters:

  • key (Object)

    key of header to write

  • value (Object)

    value of header



56
57
58
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 56

def []=(key, value)
  headers[key] = value
end

#marshal_dumpHash

Marshal serialization support.

Returns:

  • (Hash)

    the hash ready to be serialized in Marshal.



71
72
73
74
75
76
77
78
79
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 71

def marshal_dump
  {
    http_method: http_method,
    body: body,
    headers: headers,
    path: path,
    host: host
  }
end

#marshal_load(serialised) ⇒ Object

Marshal serialization support. Restores the instance variables according to the serialised.

Parameters:

  • serialised (Hash)

    the serialised object.



84
85
86
87
88
89
90
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 84

def marshal_load(serialised)
  self.http_method = serialised[:http_method]
  self.body = serialised[:body]
  self.headers = serialised[:headers]
  self.path = serialised[:path]
  self.host = serialised[:host]
end

#to_aObject



60
61
62
63
64
65
66
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 60

def to_a
  [
    self.http_method,
    self.url.to_s,
    headers: self.headers
  ]
end

#update_uri(url) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/logstash/inputs/akamai_siem/request.rb', line 33

def update_uri(url)
  if url.respond_to? :query
    if (query = url.query)
      path = url.path = Addressable::URI.unencode(url.path.dup.gsub(/\/$/, ''))
    end
  else
    anchor_index = path.index('#')
    path = path.slice(0, anchor_index) unless anchor_index.nil?
    path, query = path.split('?', 2)
  end
  self.host = url.host
  self.path = path
  self.url = url
end