class Twilio::REST::Monitor::V1::EventList
Public Class Methods
Initialize the EventList
@param [Version] version Version
that contains the resource @return [EventList] EventList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/monitor/v1/event.rb 18 def initialize(version) 19 super(version) 20 21 # Path Solution 22 @solution = {} 23 @uri = "/Events" 24 end
Public Instance Methods
When passed a block, yields EventInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/monitor/v1/event.rb 111 def each 112 limits = @version.read_limits 113 114 page = self.page(page_size: limits[:page_size], ) 115 116 @version.stream(page, 117 limit: limits[:limit], 118 page_limit: limits[:page_limit]).each {|x| yield x} 119 end
Retrieve a single page of EventInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of EventInstance
# File lib/twilio-ruby/rest/monitor/v1/event.rb 166 def get_page(target_url) 167 response = @version.domain.request( 168 'GET', 169 target_url 170 ) 171 EventPage.new(@version, response, @solution) 172 end
Lists EventInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] actor_sid Only include events initiated by this Actor. Useful
for auditing actions taken by specific users or API credentials.
@param [String] event_type Only include events of this {Event
Type}[https://www.twilio.com/docs/usage/monitor-events#event-types].
@param [String] resource_sid Only include events that refer to this resource.
Useful for discovering the history of a specific resource.
@param [String] source_ip_address Only include events that originated from this
IP address. Useful for tracking suspicious activity originating from the API or the Twilio Console.
@param [Time] start_date Only include events that occurred on or after this
date. Specify the date in GMT and {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format.
@param [Time] end_date Only include events that occurred on or before this date.
Specify the date in GMT and {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format.
@param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Array] Array of up to limit results
# File lib/twilio-ruby/rest/monitor/v1/event.rb 52 def list(actor_sid: :unset, event_type: :unset, resource_sid: :unset, source_ip_address: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil) 53 self.stream( 54 actor_sid: actor_sid, 55 event_type: event_type, 56 resource_sid: resource_sid, 57 source_ip_address: source_ip_address, 58 start_date: start_date, 59 end_date: end_date, 60 limit: limit, 61 page_size: page_size 62 ).entries 63 end
Retrieve a single page of EventInstance
records from the API. Request
is executed immediately. @param [String] actor_sid Only include events initiated by this Actor. Useful
for auditing actions taken by specific users or API credentials.
@param [String] event_type Only include events of this {Event
Type}[https://www.twilio.com/docs/usage/monitor-events#event-types].
@param [String] resource_sid Only include events that refer to this resource.
Useful for discovering the history of a specific resource.
@param [String] source_ip_address Only include events that originated from this
IP address. Useful for tracking suspicious activity originating from the API or the Twilio Console.
@param [Time] start_date Only include events that occurred on or after this
date. Specify the date in GMT and {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format.
@param [Time] end_date Only include events that occurred on or before this date.
Specify the date in GMT and {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format.
@param [String] page_token PageToken provided by the API @param [Integer] page_number Page
Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page
of EventInstance
# File lib/twilio-ruby/rest/monitor/v1/event.rb 143 def page(actor_sid: :unset, event_type: :unset, resource_sid: :unset, source_ip_address: :unset, start_date: :unset, end_date: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 144 params = Twilio::Values.of({ 145 'ActorSid' => actor_sid, 146 'EventType' => event_type, 147 'ResourceSid' => resource_sid, 148 'SourceIpAddress' => source_ip_address, 149 'StartDate' => Twilio.serialize_iso8601_datetime(start_date), 150 'EndDate' => Twilio.serialize_iso8601_datetime(end_date), 151 'PageToken' => page_token, 152 'Page' => page_number, 153 'PageSize' => page_size, 154 }) 155 156 response = @version.page('GET', @uri, params: params) 157 158 EventPage.new(@version, response, @solution) 159 end
Streams EventInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] actor_sid Only include events initiated by this Actor. Useful
for auditing actions taken by specific users or API credentials.
@param [String] event_type Only include events of this {Event
Type}[https://www.twilio.com/docs/usage/monitor-events#event-types].
@param [String] resource_sid Only include events that refer to this resource.
Useful for discovering the history of a specific resource.
@param [String] source_ip_address Only include events that originated from this
IP address. Useful for tracking suspicious activity originating from the API or the Twilio Console.
@param [Time] start_date Only include events that occurred on or after this
date. Specify the date in GMT and {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format.
@param [Time] end_date Only include events that occurred on or before this date.
Specify the date in GMT and {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format.
@param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit.
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/monitor/v1/event.rb 91 def stream(actor_sid: :unset, event_type: :unset, resource_sid: :unset, source_ip_address: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil) 92 limits = @version.read_limits(limit, page_size) 93 94 page = self.page( 95 actor_sid: actor_sid, 96 event_type: event_type, 97 resource_sid: resource_sid, 98 source_ip_address: source_ip_address, 99 start_date: start_date, 100 end_date: end_date, 101 page_size: limits[:page_size], 102 ) 103 104 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 105 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/monitor/v1/event.rb 176 def to_s 177 '#<Twilio.Monitor.V1.EventList>' 178 end