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

  • account_sid (String)

    The SID of the Account that created this Alert resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 407

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'],
        'request_variables' => payload['request_variables'],
        'resource_sid' => payload['resource_sid'],
        'response_body' => payload['response_body'],
        'response_headers' => payload['response_headers'],
        'sid' => payload['sid'],
        'url' => payload['url'],
        'request_headers' => payload['request_headers'],
        'service_sid' => payload['service_sid'],
    }

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

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Alert resource.

Returns:



452
453
454
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 452

def 
    @properties['account_sid']
end

#alert_textString

Returns The text of the alert.

Returns:

  • (String)

    The text of the alert.



458
459
460
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 458

def alert_text
    @properties['alert_text']
end

#api_versionString

Returns The API version used when the alert was generated. Can be empty for events that don’t have a specific API version.

Returns:

  • (String)

    The API version used when the alert was generated. Can be empty for events that don’t have a specific API version.



464
465
466
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 464

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:



443
444
445
446
447
448
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 443

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

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



470
471
472
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 470

def date_created
    @properties['date_created']
end

#date_generatedTime

Returns The date and time in GMT when the alert was generated specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601#UTC) format. Due to buffering, this can be different than ‘date_created`.

Returns:

  • (Time)

    The date and time in GMT when the alert was generated specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601#UTC) format. Due to buffering, this can be different than ‘date_created`.



476
477
478
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 476

def date_generated
    @properties['date_generated']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



482
483
484
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 482

def date_updated
    @properties['date_updated']
end

#error_codeString

Returns The error code for the condition that generated the alert. See the [Error Dictionary](www.twilio.com/docs/api/errors) for possible causes and solutions to the error.

Returns:

  • (String)

    The error code for the condition that generated the alert. See the [Error Dictionary](www.twilio.com/docs/api/errors) for possible causes and solutions to the error.



488
489
490
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 488

def error_code
    @properties['error_code']
end

#fetchAlertInstance

Fetch the AlertInstance

Returns:



567
568
569
570
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 567

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



581
582
583
584
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 581

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

#log_levelString

Returns The log level. Can be: ‘error`, `warning`, `notice`, or `debug`.

Returns:

  • (String)

    The log level. Can be: ‘error`, `warning`, `notice`, or `debug`.



494
495
496
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 494

def log_level
    @properties['log_level']
end

#more_infoString

Returns The URL of the page in our [Error Dictionary](www.twilio.com/docs/api/errors) with more information about the error condition.

Returns:



500
501
502
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 500

def more_info
    @properties['more_info']
end

#request_headersString

Returns The request headers of the request that generated the alert. This value is only returned when a single Alert resource is fetched.

Returns:

  • (String)

    The request headers of the request that generated the alert. This value is only returned when a single Alert resource is fetched.



554
555
556
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 554

def request_headers
    @properties['request_headers']
end

#request_methodString

Returns The method used by the request that generated the alert. If the alert was generated by a request we made to your server, this is the method we used. If the alert was generated by a request from your application to our API, this is the method your application used.

Returns:

  • (String)

    The method used by the request that generated the alert. If the alert was generated by a request we made to your server, this is the method we used. If the alert was generated by a request from your application to our API, this is the method your application used.



506
507
508
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 506

def request_method
    @properties['request_method']
end

#request_urlString

Returns The URL of the request that generated the alert. If the alert was generated by a request we made to your server, this is the URL on your server that generated the alert. If the alert was generated by a request from your application to our API, this is the URL of the resource requested.

Returns:

  • (String)

    The URL of the request that generated the alert. If the alert was generated by a request we made to your server, this is the URL on your server that generated the alert. If the alert was generated by a request from your application to our API, this is the URL of the resource requested.



512
513
514
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 512

def request_url
    @properties['request_url']
end

#request_variablesString

Returns The variables passed in the request that generated the alert. This value is only returned when a single Alert resource is fetched.

Returns:

  • (String)

    The variables passed in the request that generated the alert. This value is only returned when a single Alert resource is fetched.



518
519
520
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 518

def request_variables
    @properties['request_variables']
end

#resource_sidString

Returns The SID of the resource for which the alert was generated. For instance, if your server failed to respond to an HTTP request during the flow of a particular call, this value would be the SID of the server. This value is empty if the alert was not generated for a particular resource.

Returns:

  • (String)

    The SID of the resource for which the alert was generated. For instance, if your server failed to respond to an HTTP request during the flow of a particular call, this value would be the SID of the server. This value is empty if the alert was not generated for a particular resource.



524
525
526
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 524

def resource_sid
    @properties['resource_sid']
end

#response_bodyString

Returns The response body of the request that generated the alert. This value is only returned when a single Alert resource is fetched.

Returns:

  • (String)

    The response body of the request that generated the alert. This value is only returned when a single Alert resource is fetched.



530
531
532
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 530

def response_body
    @properties['response_body']
end

#response_headersString

Returns The response headers of the request that generated the alert. This value is only returned when a single Alert resource is fetched.

Returns:

  • (String)

    The response headers of the request that generated the alert. This value is only returned when a single Alert resource is fetched.



536
537
538
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 536

def response_headers
    @properties['response_headers']
end

#service_sidString

Returns The SID of the service or resource that generated the alert. Can be ‘null`.

Returns:

  • (String)

    The SID of the service or resource that generated the alert. Can be ‘null`.



560
561
562
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 560

def service_sid
    @properties['service_sid']
end

#sidString

Returns The unique string that we created to identify the Alert resource.

Returns:

  • (String)

    The unique string that we created to identify the Alert resource.



542
543
544
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 542

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



574
575
576
577
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 574

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

#urlString

Returns The absolute URL of the Alert resource.

Returns:

  • (String)

    The absolute URL of the Alert resource.



548
549
550
# File 'lib/twilio-ruby/rest/monitor/v1/alert.rb', line 548

def url
    @properties['url']
end