Class: OCI::Waf::Models::ReturnHttpResponseAction

Inherits:
Action
  • Object
show all
Defined in:
lib/oci/waf/models/return_http_response_action.rb

Overview

An object that represents an action which returns a defined HTTP response.

Constant Summary

Constants inherited from Action

Action::TYPE_ENUM

Instance Attribute Summary collapse

Attributes inherited from Action

#name, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Action

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ ReturnHttpResponseAction

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/oci/waf/models/return_http_response_action.rb', line 120

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

  attributes['type'] = 'RETURN_HTTP_RESPONSE'

  super(attributes)

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

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

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

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

Instance Attribute Details

#bodyOCI::Waf::Models::HttpResponseBody



82
83
84
# File 'lib/oci/waf/models/return_http_response_action.rb', line 82

def body
  @body
end

#codeInteger

[Required] Response code.

The following response codes are valid values for this property:

  • 2xx

    200 OK 201 Created 202 Accepted 206 Partial Content

  • 3xx

    300 Multiple Choices 301 Moved Permanently 302 Found 303 See Other 307 Temporary Redirect

  • 4xx

    400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found 405 Method Not Allowed 408 Request Timeout 409 Conflict 411 Length Required 412 Precondition Failed 413 Payload Too Large 414 URI Too Long 415 Unsupported Media Type 416 Range Not Satisfiable 422 Unprocessable Entity 494 Request Header Too Large 495 Cert Error 496 No Cert 497 HTTP to HTTPS

  • 5xx

    500 Internal Server Error 501 Not Implemented 502 Bad Gateway 503 Service Unavailable 504 Gateway Timeout 507 Insufficient Storage

Example: 200

Returns:

  • (Integer)


63
64
65
# File 'lib/oci/waf/models/return_http_response_action.rb', line 63

def code
  @code
end

#headersArray<OCI::Waf::Models::ResponseHeader>

Adds headers defined in this array for HTTP response.

Hop-by-hop headers are not allowed to be set:

  • Connection

  • Keep-Alive

  • Proxy-Authenticate

  • Proxy-Authorization

  • TE

  • Trailer

  • Transfer-Encoding

  • Upgrade



79
80
81
# File 'lib/oci/waf/models/return_http_response_action.rb', line 79

def headers
  @headers
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
# File 'lib/oci/waf/models/return_http_response_action.rb', line 85

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'type': :'type',
    'name': :'name',
    'code': :'code',
    'headers': :'headers',
    'body': :'body'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/oci/waf/models/return_http_response_action.rb', line 98

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'type': :'String',
    'name': :'String',
    'code': :'Integer',
    'headers': :'Array<OCI::Waf::Models::ResponseHeader>',
    'body': :'OCI::Waf::Models::HttpResponseBody'
    # 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



144
145
146
147
148
149
150
151
152
153
# File 'lib/oci/waf/models/return_http_response_action.rb', line 144

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

  self.class == other.class &&
    type == other.type &&
    name == other.name &&
    code == other.code &&
    headers == other.headers &&
    body == other.body
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



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/oci/waf/models/return_http_response_action.rb', line 178

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


158
159
160
# File 'lib/oci/waf/models/return_http_response_action.rb', line 158

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



167
168
169
# File 'lib/oci/waf/models/return_http_response_action.rb', line 167

def hash
  [type, name, code, headers, body].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



211
212
213
214
215
216
217
218
219
220
# File 'lib/oci/waf/models/return_http_response_action.rb', line 211

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



205
206
207
# File 'lib/oci/waf/models/return_http_response_action.rb', line 205

def to_s
  to_hash.to_s
end