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):



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

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



84
85
86
# File 'lib/oci/waf/models/return_http_response_action.rb', line 84

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 429 Too Many Requests 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)


65
66
67
# File 'lib/oci/waf/models/return_http_response_action.rb', line 65

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



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

def headers
  @headers
end

Class Method Details

.attribute_mapObject

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



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/oci/waf/models/return_http_response_action.rb', line 87

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.



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

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



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

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



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

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


160
161
162
# File 'lib/oci/waf/models/return_http_response_action.rb', line 160

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



169
170
171
# File 'lib/oci/waf/models/return_http_response_action.rb', line 169

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



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

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



207
208
209
# File 'lib/oci/waf/models/return_http_response_action.rb', line 207

def to_s
  to_hash.to_s
end