class Twilio::REST::Events::V1::SinkList
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the SinkList
@param [Version] version Version
that contains the resource @return [SinkList] SinkList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/events/v1/sink.rb 20 def initialize(version) 21 super(version) 22 23 # Path Solution 24 @solution = {} 25 @uri = "/Sinks" 26 end
Public Instance Methods
Create the SinkInstance
@param [String] description A human readable description for the Sink **This
value should not contain PII.**
@param [Hash] sink_configuration The information required for Twilio
to connect
to the provided Sink encoded as JSON.
@param [sink.SinkType] sink_type The Sink type. Can only be “kinesis” or
"webhook" currently.
@return [SinkInstance] Created SinkInstance
# File lib/twilio-ruby/rest/events/v1/sink.rb 37 def create(description: nil, sink_configuration: nil, sink_type: nil) 38 data = Twilio::Values.of({ 39 'Description' => description, 40 'SinkConfiguration' => Twilio.serialize_object(sink_configuration), 41 'SinkType' => sink_type, 42 }) 43 44 payload = @version.create('POST', @uri, data: data) 45 46 SinkInstance.new(@version, payload, ) 47 end
When passed a block, yields SinkInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/events/v1/sink.rb 95 def each 96 limits = @version.read_limits 97 98 page = self.page(page_size: limits[:page_size], ) 99 100 @version.stream(page, 101 limit: limits[:limit], 102 page_limit: limits[:page_limit]).each {|x| yield x} 103 end
Retrieve a single page of SinkInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of SinkInstance
# File lib/twilio-ruby/rest/events/v1/sink.rb 135 def get_page(target_url) 136 response = @version.domain.request( 137 'GET', 138 target_url 139 ) 140 SinkPage.new(@version, response, @solution) 141 end
Lists SinkInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Boolean] in_use A boolean query parameter filtering the results to
return sinks used/not used by a subscription.
@param [String] status A String query parameter filtering the results by status
`initialized`, `validating`, `active` or `failed`.
@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/events/v1/sink.rb 64 def list(in_use: :unset, status: :unset, limit: nil, page_size: nil) 65 self.stream(in_use: in_use, status: status, limit: limit, page_size: page_size).entries 66 end
Retrieve a single page of SinkInstance
records from the API. Request
is executed immediately. @param [Boolean] in_use A boolean query parameter filtering the results to
return sinks used/not used by a subscription.
@param [String] status A String query parameter filtering the results by status
`initialized`, `validating`, `active` or `failed`.
@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 SinkInstance
# File lib/twilio-ruby/rest/events/v1/sink.rb 116 def page(in_use: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 117 params = Twilio::Values.of({ 118 'InUse' => in_use, 119 'Status' => status, 120 'PageToken' => page_token, 121 'Page' => page_number, 122 'PageSize' => page_size, 123 }) 124 125 response = @version.page('GET', @uri, params: params) 126 127 SinkPage.new(@version, response, @solution) 128 end
Streams SinkInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Boolean] in_use A boolean query parameter filtering the results to
return sinks used/not used by a subscription.
@param [String] status A String query parameter filtering the results by status
`initialized`, `validating`, `active` or `failed`.
@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/events/v1/sink.rb 83 def stream(in_use: :unset, status: :unset, limit: nil, page_size: nil) 84 limits = @version.read_limits(limit, page_size) 85 86 page = self.page(in_use: in_use, status: status, page_size: limits[:page_size], ) 87 88 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 89 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/events/v1/sink.rb 145 def to_s 146 '#<Twilio.Events.V1.SinkList>' 147 end