class Twilio::REST::Api::V2010::AccountContext::SipList::IpAccessControlListContext::IpAddressList
Public Class Methods
Initialize the IpAddressList
@param [Version] version Version
that contains the resource @param [String] account_sid The unique id of the Account that is responsible for
this resource.
@param [String] ip_access_control_list_sid The unique id of the
IpAccessControlList resource that includes this resource.
@return [IpAddressList] IpAddressList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb 25 def initialize(version, account_sid: nil, ip_access_control_list_sid: nil) 26 super(version) 27 28 # Path Solution 29 @solution = {account_sid: account_sid, ip_access_control_list_sid: ip_access_control_list_sid} 30 @uri = "/Accounts/#{@solution[:account_sid]}/SIP/IpAccessControlLists/#{@solution[:ip_access_control_list_sid]}/IpAddresses.json" 31 end
Public Instance Methods
Create the IpAddressInstance
@param [String] friendly_name A human readable descriptive text for this
resource, up to 64 characters long.
@param [String] ip_address An IP address in dotted decimal notation from which
you want to accept traffic. Any SIP requests from this IP address will be allowed by Twilio. IPv4 only supported today.
@param [String] cidr_prefix_length An integer representing the length of the
CIDR prefix to use with this IP address when accepting traffic. By default the entire IP address is used.
@return [IpAddressInstance] Created IpAddressInstance
# File lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb 124 def create(friendly_name: nil, ip_address: nil, cidr_prefix_length: :unset) 125 data = Twilio::Values.of({ 126 'FriendlyName' => friendly_name, 127 'IpAddress' => ip_address, 128 'CidrPrefixLength' => cidr_prefix_length, 129 }) 130 131 payload = @version.create('POST', @uri, data: data) 132 133 IpAddressInstance.new( 134 @version, 135 payload, 136 account_sid: @solution[:account_sid], 137 ip_access_control_list_sid: @solution[:ip_access_control_list_sid], 138 ) 139 end
When passed a block, yields IpAddressInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb 71 def each 72 limits = @version.read_limits 73 74 page = self.page(page_size: limits[:page_size], ) 75 76 @version.stream(page, 77 limit: limits[:limit], 78 page_limit: limits[:page_limit]).each {|x| yield x} 79 end
Retrieve a single page of IpAddressInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of IpAddressInstance
# File lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb 105 def get_page(target_url) 106 response = @version.domain.request( 107 'GET', 108 target_url 109 ) 110 IpAddressPage.new(@version, response, @solution) 111 end
Lists IpAddressInstance
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/api/v2010/account/sip/ip_access_control_list/ip_address.rb 44 def list(limit: nil, page_size: nil) 45 self.stream(limit: limit, page_size: page_size).entries 46 end
Retrieve a single page of IpAddressInstance
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 IpAddressInstance
# File lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb 88 def page(page_token: :unset, page_number: :unset, page_size: :unset) 89 params = Twilio::Values.of({ 90 'PageToken' => page_token, 91 'Page' => page_number, 92 'PageSize' => page_size, 93 }) 94 95 response = @version.page('GET', @uri, params: params) 96 97 IpAddressPage.new(@version, response, @solution) 98 end
Streams IpAddressInstance
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/api/v2010/account/sip/ip_access_control_list/ip_address.rb 59 def stream(limit: nil, page_size: nil) 60 limits = @version.read_limits(limit, page_size) 61 62 page = self.page(page_size: limits[:page_size], ) 63 64 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 65 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list/ip_address.rb 143 def to_s 144 '#<Twilio.Api.V2010.IpAddressList>' 145 end