class Twilio::REST::Voice::V1::ConnectionPolicyContext::ConnectionPolicyTargetList
Public Class Methods
Initialize the ConnectionPolicyTargetList
@param [Version] version Version
that contains the resource @param [String] connection_policy_sid The SID of the Connection Policy that owns
the Target.
@return [ConnectionPolicyTargetList] ConnectionPolicyTargetList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 21 def initialize(version, connection_policy_sid: nil) 22 super(version) 23 24 # Path Solution 25 @solution = {connection_policy_sid: connection_policy_sid} 26 @uri = "/ConnectionPolicies/#{@solution[:connection_policy_sid]}/Targets" 27 end
Public Instance Methods
Create the ConnectionPolicyTargetInstance
@param [String] target The SIP address you want Twilio
to route your calls to.
This must be a `sip:` schema. `sips` is NOT supported.
@param [String] friendly_name A descriptive string that you create to describe
the resource. It is not unique and can be up to 255 characters long.
@param [String] priority The relative importance of the target. Can be an
integer from 0 to 65535, inclusive, and the default is 10. The lowest number represents the most important target.
@param [String] weight The value that determines the relative share of the load
the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive, and the default is 10. Targets with higher values receive more load than those with lower ones with the same priority.
@param [Boolean] enabled Whether the Target is enabled. The default is `true`. @return [ConnectionPolicyTargetInstance] Created ConnectionPolicyTargetInstance
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 45 def create(target: nil, friendly_name: :unset, priority: :unset, weight: :unset, enabled: :unset) 46 data = Twilio::Values.of({ 47 'Target' => target, 48 'FriendlyName' => friendly_name, 49 'Priority' => priority, 50 'Weight' => weight, 51 'Enabled' => enabled, 52 }) 53 54 payload = @version.create('POST', @uri, data: data) 55 56 ConnectionPolicyTargetInstance.new( 57 @version, 58 payload, 59 connection_policy_sid: @solution[:connection_policy_sid], 60 ) 61 end
When passed a block, yields ConnectionPolicyTargetInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 101 def each 102 limits = @version.read_limits 103 104 page = self.page(page_size: limits[:page_size], ) 105 106 @version.stream(page, 107 limit: limits[:limit], 108 page_limit: limits[:page_limit]).each {|x| yield x} 109 end
Retrieve a single page of ConnectionPolicyTargetInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of ConnectionPolicyTargetInstance
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 135 def get_page(target_url) 136 response = @version.domain.request( 137 'GET', 138 target_url 139 ) 140 ConnectionPolicyTargetPage.new(@version, response, @solution) 141 end
Lists ConnectionPolicyTargetInstance
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
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 74 def list(limit: nil, page_size: nil) 75 self.stream(limit: limit, page_size: page_size).entries 76 end
Retrieve a single page of ConnectionPolicyTargetInstance
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 ConnectionPolicyTargetInstance
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 118 def page(page_token: :unset, page_number: :unset, page_size: :unset) 119 params = Twilio::Values.of({ 120 'PageToken' => page_token, 121 'Page' => page_number, 122 'PageSize' => page_size, 123 }) 124 125 response = @version.page('GET', @uri, params: params) 126 127 ConnectionPolicyTargetPage.new(@version, response, @solution) 128 end
Streams ConnectionPolicyTargetInstance
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
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 89 def stream(limit: nil, page_size: nil) 90 limits = @version.read_limits(limit, page_size) 91 92 page = self.page(page_size: limits[:page_size], ) 93 94 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 95 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb 145 def to_s 146 '#<Twilio.Voice.V1.ConnectionPolicyTargetList>' 147 end