class Twilio::REST::Supersim::V1::UsageRecordList
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the UsageRecordList
@param [Version] version Version
that contains the resource @return [UsageRecordList] UsageRecordList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/supersim/v1/usage_record.rb 20 def initialize(version) 21 super(version) 22 23 # Path Solution 24 @solution = {} 25 @uri = "/UsageRecords" 26 end
Public Instance Methods
When passed a block, yields UsageRecordInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/supersim/v1/usage_record.rb 133 def each 134 limits = @version.read_limits 135 136 page = self.page(page_size: limits[:page_size], ) 137 138 @version.stream(page, 139 limit: limits[:limit], 140 page_limit: limits[:page_limit]).each {|x| yield x} 141 end
Retrieve a single page of UsageRecordInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of UsageRecordInstance
# File lib/twilio-ruby/rest/supersim/v1/usage_record.rb 198 def get_page(target_url) 199 response = @version.domain.request( 200 'GET', 201 target_url 202 ) 203 UsageRecordPage.new(@version, response, @solution) 204 end
Lists UsageRecordInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] sim SID or unique name of a Sim resource. Only show UsageRecords
representing usage incurred by this Super SIM.
@param [String] fleet SID or unique name of a Fleet resource. Only show
UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
@param [String] network SID of a Network resource. Only show UsageRecords
representing usage on this network.
@param [String] iso_country Alpha-2 ISO Country Code. Only show UsageRecords
representing usage in this country.
@param [usage_record.Group] group Dimension over which to aggregate usage
records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
@param [usage_record.Granularity] granularity Time-based grouping that
UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
@param [Time] start_time Only include usage that occurred at or after this time,
specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default is one month before the `end_time`.
@param [Time] end_time Only include usage that occurred before this time,
specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default is the current time.
@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/supersim/v1/usage_record.rb 62 def list(sim: :unset, fleet: :unset, network: :unset, iso_country: :unset, group: :unset, granularity: :unset, start_time: :unset, end_time: :unset, limit: nil, page_size: nil) 63 self.stream( 64 sim: sim, 65 fleet: fleet, 66 network: network, 67 iso_country: iso_country, 68 group: group, 69 granularity: granularity, 70 start_time: start_time, 71 end_time: end_time, 72 limit: limit, 73 page_size: page_size 74 ).entries 75 end
Retrieve a single page of UsageRecordInstance
records from the API. Request
is executed immediately. @param [String] sim SID or unique name of a Sim resource. Only show UsageRecords
representing usage incurred by this Super SIM.
@param [String] fleet SID or unique name of a Fleet resource. Only show
UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
@param [String] network SID of a Network resource. Only show UsageRecords
representing usage on this network.
@param [String] iso_country Alpha-2 ISO Country Code. Only show UsageRecords
representing usage in this country.
@param [usage_record.Group] group Dimension over which to aggregate usage
records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
@param [usage_record.Granularity] granularity Time-based grouping that
UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
@param [Time] start_time Only include usage that occurred at or after this time,
specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default is one month before the `end_time`.
@param [Time] end_time Only include usage that occurred before this time,
specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default is the current time.
@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 UsageRecordInstance
# File lib/twilio-ruby/rest/supersim/v1/usage_record.rb 173 def page(sim: :unset, fleet: :unset, network: :unset, iso_country: :unset, group: :unset, granularity: :unset, start_time: :unset, end_time: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 174 params = Twilio::Values.of({ 175 'Sim' => sim, 176 'Fleet' => fleet, 177 'Network' => network, 178 'IsoCountry' => iso_country, 179 'Group' => group, 180 'Granularity' => granularity, 181 'StartTime' => Twilio.serialize_iso8601_datetime(start_time), 182 'EndTime' => Twilio.serialize_iso8601_datetime(end_time), 183 'PageToken' => page_token, 184 'Page' => page_number, 185 'PageSize' => page_size, 186 }) 187 188 response = @version.page('GET', @uri, params: params) 189 190 UsageRecordPage.new(@version, response, @solution) 191 end
Streams UsageRecordInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] sim SID or unique name of a Sim resource. Only show UsageRecords
representing usage incurred by this Super SIM.
@param [String] fleet SID or unique name of a Fleet resource. Only show
UsageRecords representing usage for Super SIMs belonging to this Fleet resource at the time the usage occurred.
@param [String] network SID of a Network resource. Only show UsageRecords
representing usage on this network.
@param [String] iso_country Alpha-2 ISO Country Code. Only show UsageRecords
representing usage in this country.
@param [usage_record.Group] group Dimension over which to aggregate usage
records. Can be: `sim`, `fleet`, `network`, `isoCountry`. Default is to not aggregate across any of these dimensions, UsageRecords will be aggregated into the time buckets described by the `Granularity` parameter.
@param [usage_record.Granularity] granularity Time-based grouping that
UsageRecords should be aggregated by. Can be: `hour`, `day`, or `all`. Default is `all`. `all` returns one UsageRecord that describes the usage for the entire period.
@param [Time] start_time Only include usage that occurred at or after this time,
specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default is one month before the `end_time`.
@param [Time] end_time Only include usage that occurred before this time,
specified in {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] format. Default is the current time.
@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/supersim/v1/usage_record.rb 111 def stream(sim: :unset, fleet: :unset, network: :unset, iso_country: :unset, group: :unset, granularity: :unset, start_time: :unset, end_time: :unset, limit: nil, page_size: nil) 112 limits = @version.read_limits(limit, page_size) 113 114 page = self.page( 115 sim: sim, 116 fleet: fleet, 117 network: network, 118 iso_country: iso_country, 119 group: group, 120 granularity: granularity, 121 start_time: start_time, 122 end_time: end_time, 123 page_size: limits[:page_size], 124 ) 125 126 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 127 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/supersim/v1/usage_record.rb 208 def to_s 209 '#<Twilio.Supersim.V1.UsageRecordList>' 210 end