class Twilio::REST::Monitor::V1::AlertList

Public Class Methods

new(version) click to toggle source

Initialize the AlertList @param [Version] version Version that contains the resource @return [AlertList] AlertList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/monitor/v1/alert.rb
18 def initialize(version)
19   super(version)
20 
21   # Path Solution
22   @solution = {}
23   @uri = "/Alerts"
24 end

Public Instance Methods

each() { |x| ... } click to toggle source

When passed a block, yields AlertInstance 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/alert.rb
91 def each
92   limits = @version.read_limits
93 
94   page = self.page(page_size: limits[:page_size], )
95 
96   @version.stream(page,
97                   limit: limits[:limit],
98                   page_limit: limits[:page_limit]).each {|x| yield x}
99 end
get_page(target_url) click to toggle source

Retrieve a single page of AlertInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of AlertInstance

    # File lib/twilio-ruby/rest/monitor/v1/alert.rb
136 def get_page(target_url)
137   response = @version.domain.request(
138       'GET',
139       target_url
140   )
141   AlertPage.new(@version, response, @solution)
142 end
list(log_level: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil) click to toggle source

Lists AlertInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] log_level Only show alerts for this log-level. Can be: `error`,

`warning`, `notice`, or `debug`.

@param [Time] start_date Only include alerts that occurred on or after this date

and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or
`YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported.

@param [Time] end_date Only include alerts that occurred on or before this date

and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or
`YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported.

@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/alert.rb
45 def list(log_level: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil)
46   self.stream(
47       log_level: log_level,
48       start_date: start_date,
49       end_date: end_date,
50       limit: limit,
51       page_size: page_size
52   ).entries
53 end
page(log_level: :unset, start_date: :unset, end_date: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of AlertInstance records from the API. Request is executed immediately. @param [String] log_level Only show alerts for this log-level. Can be: `error`,

`warning`, `notice`, or `debug`.

@param [Time] start_date Only include alerts that occurred on or after this date

and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or
`YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported.

@param [Time] end_date Only include alerts that occurred on or before this date

and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or
`YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported.

@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 AlertInstance

    # File lib/twilio-ruby/rest/monitor/v1/alert.rb
116 def page(log_level: :unset, start_date: :unset, end_date: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
117   params = Twilio::Values.of({
118       'LogLevel' => log_level,
119       'StartDate' => Twilio.serialize_iso8601_datetime(start_date),
120       'EndDate' => Twilio.serialize_iso8601_datetime(end_date),
121       'PageToken' => page_token,
122       'Page' => page_number,
123       'PageSize' => page_size,
124   })
125 
126   response = @version.page('GET', @uri, params: params)
127 
128   AlertPage.new(@version, response, @solution)
129 end
stream(log_level: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil) click to toggle source

Streams AlertInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] log_level Only show alerts for this log-level. Can be: `error`,

`warning`, `notice`, or `debug`.

@param [Time] start_date Only include alerts that occurred on or after this date

and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or
`YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported.

@param [Time] end_date Only include alerts that occurred on or before this date

and time. Specify the date and time in GMT and format as `YYYY-MM-DD` or
`YYYY-MM-DDThh:mm:ssZ`. Queries for alerts older than 30 days are not supported.

@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/alert.rb
74 def stream(log_level: :unset, start_date: :unset, end_date: :unset, limit: nil, page_size: nil)
75   limits = @version.read_limits(limit, page_size)
76 
77   page = self.page(
78       log_level: log_level,
79       start_date: start_date,
80       end_date: end_date,
81       page_size: limits[:page_size],
82   )
83 
84   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
85 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/monitor/v1/alert.rb
146 def to_s
147   '#<Twilio.Monitor.V1.AlertList>'
148 end