class Twilio::REST::Preview::DeployedDevices::FleetContext::DeviceList

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.

Public Class Methods

new(version, fleet_sid: nil) click to toggle source

Initialize the DeviceList @param [Version] version Version that contains the resource @param [String] fleet_sid Specifies the unique string identifier of the Fleet

that the given Device belongs to.

@return [DeviceList] DeviceList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb
23 def initialize(version, fleet_sid: nil)
24   super(version)
25 
26   # Path Solution
27   @solution = {fleet_sid: fleet_sid}
28   @uri = "/Fleets/#{@solution[:fleet_sid]}/Devices"
29 end

Public Instance Methods

create(unique_name: :unset, friendly_name: :unset, identity: :unset, deployment_sid: :unset, enabled: :unset) click to toggle source

Create the DeviceInstance @param [String] unique_name Provides a unique and addressable name to be

assigned to this Device, to be used in addition to SID, up to 128 characters
long.

@param [String] friendly_name Provides a human readable descriptive text to be

assigned to this Device, up to 256 characters long.

@param [String] identity Provides an arbitrary string identifier representing a

human user to be associated with this Device, up to 256 characters long.

@param [String] deployment_sid Specifies the unique string identifier of the

Deployment group that this Device is going to be associated with.

@param [Boolean] enabled The enabled @return [DeviceInstance] Created DeviceInstance

   # File lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb
44 def create(unique_name: :unset, friendly_name: :unset, identity: :unset, deployment_sid: :unset, enabled: :unset)
45   data = Twilio::Values.of({
46       'UniqueName' => unique_name,
47       'FriendlyName' => friendly_name,
48       'Identity' => identity,
49       'DeploymentSid' => deployment_sid,
50       'Enabled' => enabled,
51   })
52 
53   payload = @version.create('POST', @uri, data: data)
54 
55   DeviceInstance.new(@version, payload, fleet_sid: @solution[:fleet_sid], )
56 end
each() { |x| ... } click to toggle source

When passed a block, yields DeviceInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb
100 def each
101   limits = @version.read_limits
102 
103   page = self.page(page_size: limits[:page_size], )
104 
105   @version.stream(page,
106                   limit: limits[:limit],
107                   page_limit: limits[:page_limit]).each {|x| yield x}
108 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb
137 def get_page(target_url)
138   response = @version.domain.request(
139       'GET',
140       target_url
141   )
142   DevicePage.new(@version, response, @solution)
143 end
list(deployment_sid: :unset, limit: nil, page_size: nil) click to toggle source

Lists DeviceInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] deployment_sid Filters the resulting list of Devices by a unique

string identifier of the Deployment they are associated with.

@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/preview/deployed_devices/fleet/device.rb
71 def list(deployment_sid: :unset, limit: nil, page_size: nil)
72   self.stream(deployment_sid: deployment_sid, limit: limit, page_size: page_size).entries
73 end
page(deployment_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of DeviceInstance records from the API. Request is executed immediately. @param [String] deployment_sid Filters the resulting list of Devices by a unique

string identifier of the Deployment they are associated with.

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

    # File lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb
119 def page(deployment_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
120   params = Twilio::Values.of({
121       'DeploymentSid' => deployment_sid,
122       'PageToken' => page_token,
123       'Page' => page_number,
124       'PageSize' => page_size,
125   })
126 
127   response = @version.page('GET', @uri, params: params)
128 
129   DevicePage.new(@version, response, @solution)
130 end
stream(deployment_sid: :unset, limit: nil, page_size: nil) click to toggle source

Streams DeviceInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] deployment_sid Filters the resulting list of Devices by a unique

string identifier of the Deployment they are associated with.

@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/preview/deployed_devices/fleet/device.rb
88 def stream(deployment_sid: :unset, limit: nil, page_size: nil)
89   limits = @version.read_limits(limit, page_size)
90 
91   page = self.page(deployment_sid: deployment_sid, page_size: limits[:page_size], )
92 
93   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
94 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb
147 def to_s
148   '#<Twilio.Preview.DeployedDevices.DeviceList>'
149 end