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.

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



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/oci/audit/models/response.rb', line 114

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


55
56
57
# File 'lib/oci/audit/models/response.rb', line 55

def headers
  @headers
end

#messageString

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

Returns:

  • (String)


75
76
77
# File 'lib/oci/audit/models/response.rb', line 75

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


70
71
72
# File 'lib/oci/audit/models/response.rb', line 70

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)


25
26
27
# File 'lib/oci/audit/models/response.rb', line 25

def response_time
  @response_time
end

#statusString

The status code of the response.

Example: 200

Returns:

  • (String)


17
18
19
# File 'lib/oci/audit/models/response.rb', line 17

def status
  @status
end

Class Method Details

.attribute_mapObject

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



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/oci/audit/models/response.rb', line 78

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.



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/oci/audit/models/response.rb', line 91

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



142
143
144
145
146
147
148
149
150
151
# File 'lib/oci/audit/models/response.rb', line 142

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



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

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


156
157
158
# File 'lib/oci/audit/models/response.rb', line 156

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



165
166
167
# File 'lib/oci/audit/models/response.rb', line 165

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



209
210
211
212
213
214
215
216
217
218
# File 'lib/oci/audit/models/response.rb', line 209

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



203
204
205
# File 'lib/oci/audit/models/response.rb', line 203

def to_s
  to_hash.to_s
end