Class: Twilio::REST::Monitor::V1::EventInstance

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

Instance Method Summary collapse

Constructor Details

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

Initialize the EventInstance

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 Event resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/twilio-ruby/rest/monitor/v1/event.rb', line 431

def initialize(version, payload , sid: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'actor_sid' => payload['actor_sid'],
        'actor_type' => payload['actor_type'],
        'description' => payload['description'],
        'event_data' => payload['event_data'],
        'event_date' => Twilio.deserialize_iso8601_datetime(payload['event_date']),
        'event_type' => payload['event_type'],
        'resource_sid' => payload['resource_sid'],
        'resource_type' => payload['resource_type'],
        'sid' => payload['sid'],
        'source' => payload['source'],
        'source_ip_address' => payload['source_ip_address'],
        'url' => payload['url'],
        'links' => payload['links'],
    }

    # 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 Event resource.

Returns:



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

def 
    @properties['account_sid']
end

#actor_sidString

Returns The SID of the actor that caused the event, if available. This can be either a User ID (matching the pattern ‘^US32$`) or an Account SID (matching the pattern `^AC32$`). If the actor’s SID isn’t available, this field will be ‘null`.

Returns:

  • (String)

    The SID of the actor that caused the event, if available. This can be either a User ID (matching the pattern ‘^US32$`) or an Account SID (matching the pattern `^AC32$`). If the actor’s SID isn’t available, this field will be ‘null`.



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

def actor_sid
    @properties['actor_sid']
end

#actor_typeString

Returns The type of actor that caused the event. Can be: ‘user` for a change made by a logged-in user in the Twilio Console, `account` for an event caused by an API request by an authenticating Account, `twilio-admin` for an event caused by a Twilio employee, and so on.

Returns:

  • (String)

    The type of actor that caused the event. Can be: ‘user` for a change made by a logged-in user in the Twilio Console, `account` for an event caused by an API request by an authenticating Account, `twilio-admin` for an event caused by a Twilio employee, and so on.



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

def actor_type
    @properties['actor_type']
end

#contextEventContext

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

Returns:



462
463
464
465
466
467
# File 'lib/twilio-ruby/rest/monitor/v1/event.rb', line 462

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

#descriptionString

Returns A description of the event. Can be ‘null`.

Returns:

  • (String)

    A description of the event. Can be ‘null`.



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

def description
    @properties['description']
end

#event_dataHash

Returns An object with additional data about the event. The contents depend on ‘event_type`. For example, event-types of the form `RESOURCE.updated`, this value contains a `resource_properties` dictionary that describes the previous and updated properties of the resource.

Returns:

  • (Hash)

    An object with additional data about the event. The contents depend on ‘event_type`. For example, event-types of the form `RESOURCE.updated`, this value contains a `resource_properties` dictionary that describes the previous and updated properties of the resource.



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

def event_data
    @properties['event_data']
end

#event_dateTime

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

Returns:



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

def event_date
    @properties['event_date']
end

#event_typeString

Returns The event’s type. Event-types are typically in the form: ‘RESOURCE_TYPE.ACTION`, where `RESOURCE_TYPE` is the type of resource that was affected and `ACTION` is what happened to it. For example, `phone-number.created`. For a full list of all event-types, see the [Monitor Event Types](www.twilio.com/docs/usage/monitor-events#event-types).

Returns:

  • (String)

    The event’s type. Event-types are typically in the form: ‘RESOURCE_TYPE.ACTION`, where `RESOURCE_TYPE` is the type of resource that was affected and `ACTION` is what happened to it. For example, `phone-number.created`. For a full list of all event-types, see the [Monitor Event Types](www.twilio.com/docs/usage/monitor-events#event-types).



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

def event_type
    @properties['event_type']
end

#fetchEventInstance

Fetch the EventInstance

Returns:



556
557
558
559
# File 'lib/twilio-ruby/rest/monitor/v1/event.rb', line 556

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



570
571
572
573
# File 'lib/twilio-ruby/rest/monitor/v1/event.rb', line 570

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

Returns The absolute URLs of related resources.

Returns:

  • (Hash)

    The absolute URLs of related resources.



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

def links
    @properties['links']
end

#resource_sidString

Returns The SID of the resource that was affected.

Returns:

  • (String)

    The SID of the resource that was affected.



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

def resource_sid
    @properties['resource_sid']
end

#resource_typeString

Returns The type of resource that was affected. For a full list of all resource-types, see the [Monitor Event Types](www.twilio.com/docs/usage/monitor-events#event-types).

Returns:



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

def resource_type
    @properties['resource_type']
end

#sidString

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

Returns:

  • (String)

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



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

def sid
    @properties['sid']
end

#sourceString

Returns The originating system or interface that caused the event. Can be: ‘web` for events caused by user action in the Twilio Console, `api` for events caused by a request to our API, or `twilio` for events caused by an automated or internal Twilio system.

Returns:

  • (String)

    The originating system or interface that caused the event. Can be: ‘web` for events caused by user action in the Twilio Console, `api` for events caused by a request to our API, or `twilio` for events caused by an automated or internal Twilio system.



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

def source
    @properties['source']
end

#source_ip_addressString

Returns The IP address of the source, if the source is outside the Twilio cloud. This value is ‘null` for events with `source` of `twilio`.

Returns:

  • (String)

    The IP address of the source, if the source is outside the Twilio cloud. This value is ‘null` for events with `source` of `twilio`



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

def source_ip_address
    @properties['source_ip_address']
end

#to_sObject

Provide a user friendly representation



563
564
565
566
# File 'lib/twilio-ruby/rest/monitor/v1/event.rb', line 563

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

#urlString

Returns The absolute URL of the resource that was affected. Can be ‘null`.

Returns:

  • (String)

    The absolute URL of the resource that was affected. Can be ‘null`.



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

def url
    @properties['url']
end