Class: OCI::Audit::Models::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/audit/models/response.rb

Overview

A container object for response attributes.

Example:

—– { "status": "200", "responseTime": "2019-09-18T00:10:59.278Z", "headers": { "ETag": [ "<unique_ID>" ], "Connection": [ "close" ], "Content-Length": [ "1828" ], "opc-request-id": [ "<unique_ID>" ], "Date": [ "Wed, 18 Sep 2019 00:10:59 GMT" ], "Content-Type": [ "application/json" ] }, "payload": { "resourceName": "my_instance", "id": "ocid1.instance.oc1.phx.<unique_ID>" }, "message": null } —–

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Response

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :status (String)

    The value to assign to the #status property

  • :response_time (DateTime)

    The value to assign to the #response_time property

  • :headers (Hash<String, Array<String>>)

    The value to assign to the #headers property

  • :payload (Hash<String, Object>)

    The value to assign to the #payload property

  • :message (String)

    The value to assign to the #message property



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/oci/audit/models/response.rb', line 147

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.status = attributes[:'status'] if attributes[:'status']

  self.response_time = attributes[:'responseTime'] if attributes[:'responseTime']

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

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

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

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

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

Instance Attribute Details

#headersHash<String, Array<String>>

The headers of the response.

Example:

—– { "ETag": [ "<unique_ID>" ], "Connection": [ "close" ], "Content-Length": [ "1828" ], "opc-request-id": [ "<unique_ID>" ], "Date": [ "Wed, 18 Sep 2019 00:10:59 GMT" ], "Content-Type": [ "application/json" ] } —–

Returns:

  • (Hash<String, Array<String>>)


88
89
90
# File 'lib/oci/audit/models/response.rb', line 88

def headers
  @headers
end

#messageString

A friendly description of what happened during the operation. Use this for troubleshooting.

Returns:

  • (String)


108
109
110
# File 'lib/oci/audit/models/response.rb', line 108

def message
  @message
end

#payloadHash<String, Object>

This value is included for backward compatibility with the Audit version 1 schema, where it contained metadata of interest from the response payload.

Example:

—– { "resourceName": "my_instance", "id": "ocid1.instance.oc1.phx.<unique_ID>" } —–

Returns:

  • (Hash<String, Object>)


103
104
105
# File 'lib/oci/audit/models/response.rb', line 103

def payload
  @payload
end

#response_timeDateTime

The time of the response to the audited request, expressed in RFC 3339 timestamp format.

Example: 2019-09-18T00:10:59.278Z

Returns:

  • (DateTime)


58
59
60
# File 'lib/oci/audit/models/response.rb', line 58

def response_time
  @response_time
end

#statusString

The status code of the response.

Example: 200

Returns:

  • (String)


50
51
52
# File 'lib/oci/audit/models/response.rb', line 50

def status
  @status
end

Class Method Details

.attribute_mapObject

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



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/oci/audit/models/response.rb', line 111

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'status': :'status',
    'response_time': :'responseTime',
    'headers': :'headers',
    'payload': :'payload',
    'message': :'message'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/oci/audit/models/response.rb', line 124

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'status': :'String',
    'response_time': :'DateTime',
    'headers': :'Hash<String, Array<String>>',
    'payload': :'Hash<String, Object>',
    'message': :'String'
    # 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



175
176
177
178
179
180
181
182
183
184
# File 'lib/oci/audit/models/response.rb', line 175

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

  self.class == other.class &&
    status == other.status &&
    response_time == other.response_time &&
    headers == other.headers &&
    payload == other.payload &&
    message == other.message
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



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/oci/audit/models/response.rb', line 209

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


189
190
191
# File 'lib/oci/audit/models/response.rb', line 189

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



198
199
200
# File 'lib/oci/audit/models/response.rb', line 198

def hash
  [status, response_time, headers, payload, message].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



242
243
244
245
246
247
248
249
250
251
# File 'lib/oci/audit/models/response.rb', line 242

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



236
237
238
# File 'lib/oci/audit/models/response.rb', line 236

def to_s
  to_hash.to_s
end