class Twilio::REST::Preview::Understand::AssistantContext::QueryList

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, assistant_sid: nil) click to toggle source

Initialize the QueryList @param [Version] version Version that contains the resource @param [String] assistant_sid The unique ID of the parent Assistant. @return [QueryList] QueryList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/preview/understand/assistant/query.rb
22 def initialize(version, assistant_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {assistant_sid: assistant_sid}
27   @uri = "/Assistants/#{@solution[:assistant_sid]}/Queries"
28 end

Public Instance Methods

create(language: nil, query: nil, tasks: :unset, model_build: :unset, field: :unset) click to toggle source

Create the QueryInstance @param [String] language An ISO language-country string of the sample. @param [String] query A user-provided string that uniquely identifies this

resource as an alternative to the sid. It can be up to 2048 characters long.

@param [String] tasks Constraints the query to a set of tasks. Useful when you

need to constrain the paths the user can take. Tasks should be comma separated
*task-unique-name-1*, *task-unique-name-2*

@param [String] model_build The Model Build Sid or unique name of the Model

Build to be queried.

@param [String] field Constraints the query to a given Field with an task.

Useful when you know the Field you are expecting. It accepts one field in the
format *task-unique-name-1*:*field-unique-name*

@return [QueryInstance] Created QueryInstance

    # File lib/twilio-ruby/rest/preview/understand/assistant/query.rb
153 def create(language: nil, query: nil, tasks: :unset, model_build: :unset, field: :unset)
154   data = Twilio::Values.of({
155       'Language' => language,
156       'Query' => query,
157       'Tasks' => tasks,
158       'ModelBuild' => model_build,
159       'Field' => field,
160   })
161 
162   payload = @version.create('POST', @uri, data: data)
163 
164   QueryInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
165 end
each() { |x| ... } click to toggle source

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

   # File lib/twilio-ruby/rest/preview/understand/assistant/query.rb
89 def each
90   limits = @version.read_limits
91 
92   page = self.page(page_size: limits[:page_size], )
93 
94   @version.stream(page,
95                   limit: limits[:limit],
96                   page_limit: limits[:page_limit]).each {|x| yield x}
97 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/preview/understand/assistant/query.rb
131 def get_page(target_url)
132   response = @version.domain.request(
133       'GET',
134       target_url
135   )
136   QueryPage.new(@version, response, @solution)
137 end
list(language: :unset, model_build: :unset, status: :unset, limit: nil, page_size: nil) click to toggle source

Lists QueryInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] language An ISO language-country string of the sample. @param [String] model_build The Model Build Sid or unique name of the Model

Build to be queried.

@param [String] status A string that described the query status. The values can

be: pending_review, reviewed, discarded

@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/understand/assistant/query.rb
46 def list(language: :unset, model_build: :unset, status: :unset, limit: nil, page_size: nil)
47   self.stream(
48       language: language,
49       model_build: model_build,
50       status: status,
51       limit: limit,
52       page_size: page_size
53   ).entries
54 end
page(language: :unset, model_build: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of QueryInstance records from the API. Request is executed immediately. @param [String] language An ISO language-country string of the sample. @param [String] model_build The Model Build Sid or unique name of the Model

Build to be queried.

@param [String] status A string that described the query status. The values can

be: pending_review, reviewed, discarded

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

    # File lib/twilio-ruby/rest/preview/understand/assistant/query.rb
111 def page(language: :unset, model_build: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
112   params = Twilio::Values.of({
113       'Language' => language,
114       'ModelBuild' => model_build,
115       'Status' => status,
116       'PageToken' => page_token,
117       'Page' => page_number,
118       'PageSize' => page_size,
119   })
120 
121   response = @version.page('GET', @uri, params: params)
122 
123   QueryPage.new(@version, response, @solution)
124 end
stream(language: :unset, model_build: :unset, status: :unset, limit: nil, page_size: nil) click to toggle source

Streams QueryInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] language An ISO language-country string of the sample. @param [String] model_build The Model Build Sid or unique name of the Model

Build to be queried.

@param [String] status A string that described the query status. The values can

be: pending_review, reviewed, discarded

@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/understand/assistant/query.rb
72 def stream(language: :unset, model_build: :unset, status: :unset, limit: nil, page_size: nil)
73   limits = @version.read_limits(limit, page_size)
74 
75   page = self.page(
76       language: language,
77       model_build: model_build,
78       status: status,
79       page_size: limits[:page_size],
80   )
81 
82   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
83 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/preview/understand/assistant/query.rb
169 def to_s
170   '#<Twilio.Preview.Understand.QueryList>'
171 end