Class: Twilio::REST::Monitor::V1::AlertInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/monitor/v1/alert.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ AlertInstance

Initialize the AlertInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    The sid



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 252

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'alert_text' => payload['alert_text'],
      'api_version' => payload['api_version'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_generated' => Twilio.deserialize_iso8601_datetime(payload['date_generated']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'error_code' => payload['error_code'],
      'log_level' => payload['log_level'],
      'more_info' => payload['more_info'],
      'request_method' => payload['request_method'],
      'request_url' => payload['request_url'],
      'resource_sid' => payload['resource_sid'],
      'sid' => payload['sid'],
      'url' => payload['url'],
      'request_variables' => payload['request_variables'],
      'response_body' => payload['response_body'],
      'response_headers' => payload['response_headers'],
  }

  # Context
  @instance_context = nil
  @params = {'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The unique id of the Account responsible for this alert.

Returns:

  • (String)

    The unique id of the Account responsible for this alert.



294
295
296
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 294

def 
  @properties['account_sid']
end

#alert_textString

Returns The text of the alert.

Returns:

  • (String)

    The text of the alert.



300
301
302
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 300

def alert_text
  @properties['alert_text']
end

#api_versionString

Returns The version of the Twilio API in use when this alert was generated.

Returns:

  • (String)

    The version of the Twilio API in use when this alert was generated.



306
307
308
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 306

def api_version
  @properties['api_version']
end

#contextAlertContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



285
286
287
288
289
290
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 285

def context
  unless @instance_context
    @instance_context = AlertContext.new(@version, @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The date that this resource was created, given in ISO 8601 format.

Returns:

  • (Time)

    The date that this resource was created, given in ISO 8601 format.



312
313
314
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 312

def date_created
  @properties['date_created']
end

#date_generatedTime

Returns The date the alert was actually generated, given in ISO 8601 format.

Returns:

  • (Time)

    The date the alert was actually generated, given in ISO 8601 format.



318
319
320
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 318

def date_generated
  @properties['date_generated']
end

#date_updatedTime

Returns The most recent date that this resource was updated, given in ISO 8601 format.

Returns:

  • (Time)

    The most recent date that this resource was updated, given in ISO 8601 format.



324
325
326
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 324

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the AlertInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



404
405
406
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 404

def delete
  context.delete
end

#error_codeString

Returns A unique error code for the error condition.

Returns:

  • (String)

    A unique error code for the error condition.



330
331
332
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 330

def error_code
  @properties['error_code']
end

#fetchAlertInstance

Fetch a AlertInstance

Returns:



397
398
399
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 397

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



417
418
419
420
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 417

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Monitor.V1.AlertInstance #{values}>"
end

#log_levelString

Returns A string representing the log level.

Returns:

  • (String)

    A string representing the log level.



336
337
338
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 336

def log_level
  @properties['log_level']
end

#more_infoString

Returns A URL for more information about the error condition.

Returns:

  • (String)

    A URL for more information about the error condition.



342
343
344
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 342

def more_info
  @properties['more_info']
end

#request_methodString

Returns If the Alert was generated by a request Twilio made to your server, this will be the request method used when Twilio made the request to your server.

Returns:

  • (String)

    If the Alert was generated by a request Twilio made to your server, this will be the request method used when Twilio made the request to your server.



348
349
350
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 348

def request_method
  @properties['request_method']
end

#request_urlString

Returns If the Alert was generated by a request Twilio made to your server, this will be the URL on your server that generated the alert.

Returns:

  • (String)

    If the Alert was generated by a request Twilio made to your server, this will be the URL on your server that generated the alert.



354
355
356
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 354

def request_url
  @properties['request_url']
end

#request_variablesString

Returns The request_variables.

Returns:

  • (String)

    The request_variables



360
361
362
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 360

def request_variables
  @properties['request_variables']
end

#resource_sidString

Returns The unique ID of the resource for which the Alert was generated.

Returns:

  • (String)

    The unique ID of the resource for which the Alert was generated.



366
367
368
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 366

def resource_sid
  @properties['resource_sid']
end

#response_bodyString

Returns The response_body.

Returns:

  • (String)

    The response_body



372
373
374
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 372

def response_body
  @properties['response_body']
end

#response_headersString

Returns The response_headers.

Returns:

  • (String)

    The response_headers



378
379
380
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 378

def response_headers
  @properties['response_headers']
end

#sidString

Returns A 34 character string that uniquely identifies this Alert.

Returns:

  • (String)

    A 34 character string that uniquely identifies this Alert.



384
385
386
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 384

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



410
411
412
413
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 410

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Monitor.V1.AlertInstance #{values}>"
end

#urlString

Returns The absolute URL for this resource.

Returns:

  • (String)

    The absolute URL for this resource.



390
391
392
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 390

def url
  @properties['url']
end