## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class Events < Domain class V1 < Version ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class SinkList < ListResource ## # Initialize the SinkList # @param [Version] version Version that contains the resource # @return [SinkList] SinkList def initialize(version) super(version) # Path Solution @solution = {} @uri = "/Sinks" end ## # Create the SinkInstance # @param [String] description The description # @param [Hash] sink_configuration The sink_configuration # @param [sink.SinkType] sink_type The sink_type # @return [SinkInstance] Created SinkInstance def create(description: nil, sink_configuration: nil, sink_type: nil) data = Twilio::Values.of({ 'Description' => description, 'SinkConfiguration' => Twilio.serialize_object(sink_configuration), 'SinkType' => sink_type, }) payload = @version.create('POST', @uri, data: data) SinkInstance.new(@version, payload, ) 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 [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 def list(limit: nil, page_size: nil) self.stream(limit: limit, page_size: page_size).entries 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 [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 def stream(limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page(page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 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. def each limits = @version.read_limits page = self.page(page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]).each {|x| yield x} end ## # Retrieve a single page of SinkInstance records from the API. # Request is executed immediately. # @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 def page(page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, }) response = @version.page('GET', @uri, params: params) SinkPage.new(@version, response, @solution) 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 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) SinkPage.new(@version, response, @solution) end ## # Provide a user friendly representation def to_s '#' end end ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class SinkPage < Page ## # Initialize the SinkPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [SinkPage] SinkPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of SinkInstance # @param [Hash] payload Payload response from the API # @return [SinkInstance] SinkInstance def get_instance(payload) SinkInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '' end end ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class SinkContext < InstanceContext ## # Initialize the SinkContext # @param [Version] version Version that contains the resource # @param [String] sid The sid # @return [SinkContext] SinkContext def initialize(version, sid) super(version) # Path Solution @solution = {sid: sid, } @uri = "/Sinks/#{@solution[:sid]}" # Dependents @sink_test = nil @sink_validate = nil end ## # Fetch the SinkInstance # @return [SinkInstance] Fetched SinkInstance def fetch payload = @version.fetch('GET', @uri) SinkInstance.new(@version, payload, sid: @solution[:sid], ) end ## # Delete the SinkInstance # @return [Boolean] true if delete succeeds, false otherwise def delete @version.delete('DELETE', @uri) end ## # Access the sink_test # @return [SinkTestList] # @return [SinkTestContext] def sink_test unless @sink_test @sink_test = SinkTestList.new(@version, sid: @solution[:sid], ) end @sink_test end ## # Access the sink_validate # @return [SinkValidateList] # @return [SinkValidateContext] def sink_validate unless @sink_validate @sink_validate = SinkValidateList.new(@version, sid: @solution[:sid], ) end @sink_validate end ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end ## # Provide a detailed, user friendly representation def inspect context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end end ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class SinkInstance < InstanceResource ## # Initialize the SinkInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] sid The sid # @return [SinkInstance] SinkInstance def initialize(version, payload, sid: nil) super(version) # Marshaled Properties @properties = { 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'description' => payload['description'], 'sid' => payload['sid'], 'sink_configuration' => payload['sink_configuration'], 'sink_type' => payload['sink_type'], 'status' => payload['status'], 'url' => payload['url'], 'links' => payload['links'], } # Context @instance_context = nil @params = {'sid' => sid || @properties['sid'], } end ## # Generate an instance context for the instance, the context is capable of # performing various actions. All instance actions are proxied to the context # @return [SinkContext] SinkContext for this SinkInstance def context unless @instance_context @instance_context = SinkContext.new(@version, @params['sid'], ) end @instance_context end ## # @return [Time] The date_created def date_created @properties['date_created'] end ## # @return [Time] The date_updated def date_updated @properties['date_updated'] end ## # @return [String] The description def description @properties['description'] end ## # @return [String] The sid def sid @properties['sid'] end ## # @return [Hash] The sink_configuration def sink_configuration @properties['sink_configuration'] end ## # @return [sink.SinkType] The sink_type def sink_type @properties['sink_type'] end ## # @return [sink.Status] The status def status @properties['status'] end ## # @return [String] The url def url @properties['url'] end ## # @return [String] The links def links @properties['links'] end ## # Fetch the SinkInstance # @return [SinkInstance] Fetched SinkInstance def fetch context.fetch end ## # Delete the SinkInstance # @return [Boolean] true if delete succeeds, false otherwise def delete context.delete end ## # Access the sink_test # @return [sink_test] sink_test def sink_test context.sink_test end ## # Access the sink_validate # @return [sink_validate] sink_validate def sink_validate context.sink_validate end ## # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "" end ## # Provide a detailed, user friendly representation def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "" end end end end end end