class Twilio::REST::Autopilot::V1::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 SID of the

{Assistant}[https://www.twilio.com/docs/autopilot/api/assistant] that is the
parent of the resource.

@return [QueryList] QueryList

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

Public Instance Methods

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

Create the QueryInstance @param [String] language The {ISO

language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html]
string that specifies the language used for the new query. For example: `en-US`.

@param [String] query The end-user's natural language input. It can be up to

2048 characters long.

@param [String] tasks The list of tasks to limit the new query to. Tasks are

expressed as a comma-separated list of task `unique_name` values. For example,
`task-unique_name-1, task-unique_name-2`. Listing specific tasks is useful to
constrain the paths that a user can take.

@param [String] model_build The SID or unique name of the {Model

Build}[https://www.twilio.com/docs/autopilot/api/model-build] to be queried.

@return [QueryInstance] Created QueryInstance

    # File lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb
173 def create(language: nil, query: nil, tasks: :unset, model_build: :unset)
174   data = Twilio::Values.of({
175       'Language' => language,
176       'Query' => query,
177       'Tasks' => tasks,
178       'ModelBuild' => model_build,
179   })
180 
181   payload = @version.create('POST', @uri, data: data)
182 
183   QueryInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
184 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/autopilot/v1/assistant/query.rb
103 def each
104   limits = @version.read_limits
105 
106   page = self.page(page_size: limits[:page_size], )
107 
108   @version.stream(page,
109                   limit: limits[:limit],
110                   page_limit: limits[:page_limit]).each {|x| yield x}
111 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/autopilot/v1/assistant/query.rb
151 def get_page(target_url)
152   response = @version.domain.request(
153       'GET',
154       target_url
155   )
156   QueryPage.new(@version, response, @solution)
157 end
list(language: :unset, model_build: :unset, status: :unset, dialogue_sid: :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 The {ISO

language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html]
string that specifies the language used by the Query resources to read. For
example: `en-US`.

@param [String] model_build The SID or unique name of the {Model

Build}[https://www.twilio.com/docs/autopilot/api/model-build] to be queried.

@param [String] status The status of the resources to read. Can be:

`pending-review`, `reviewed`, or `discarded`

@param [String] dialogue_sid The SID of the

{Dialogue}[https://www.twilio.com/docs/autopilot/api/dialogue].

@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/autopilot/v1/assistant/query.rb
53 def list(language: :unset, model_build: :unset, status: :unset, dialogue_sid: :unset, limit: nil, page_size: nil)
54   self.stream(
55       language: language,
56       model_build: model_build,
57       status: status,
58       dialogue_sid: dialogue_sid,
59       limit: limit,
60       page_size: page_size
61   ).entries
62 end
page(language: :unset, model_build: :unset, status: :unset, dialogue_sid: :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 The {ISO

language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html]
string that specifies the language used by the Query resources to read. For
example: `en-US`.

@param [String] model_build The SID or unique name of the {Model

Build}[https://www.twilio.com/docs/autopilot/api/model-build] to be queried.

@param [String] status The status of the resources to read. Can be:

`pending-review`, `reviewed`, or `discarded`

@param [String] dialogue_sid The SID of the

{Dialogue}[https://www.twilio.com/docs/autopilot/api/dialogue].

@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/autopilot/v1/assistant/query.rb
130 def page(language: :unset, model_build: :unset, status: :unset, dialogue_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
131   params = Twilio::Values.of({
132       'Language' => language,
133       'ModelBuild' => model_build,
134       'Status' => status,
135       'DialogueSid' => dialogue_sid,
136       'PageToken' => page_token,
137       'Page' => page_number,
138       'PageSize' => page_size,
139   })
140 
141   response = @version.page('GET', @uri, params: params)
142 
143   QueryPage.new(@version, response, @solution)
144 end
stream(language: :unset, model_build: :unset, status: :unset, dialogue_sid: :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 The {ISO

language-country}[https://docs.oracle.com/cd/E13214_01/wli/docs92/xref/xqisocodes.html]
string that specifies the language used by the Query resources to read. For
example: `en-US`.

@param [String] model_build The SID or unique name of the {Model

Build}[https://www.twilio.com/docs/autopilot/api/model-build] to be queried.

@param [String] status The status of the resources to read. Can be:

`pending-review`, `reviewed`, or `discarded`

@param [String] dialogue_sid The SID of the

{Dialogue}[https://www.twilio.com/docs/autopilot/api/dialogue].

@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/autopilot/v1/assistant/query.rb
85 def stream(language: :unset, model_build: :unset, status: :unset, dialogue_sid: :unset, limit: nil, page_size: nil)
86   limits = @version.read_limits(limit, page_size)
87 
88   page = self.page(
89       language: language,
90       model_build: model_build,
91       status: status,
92       dialogue_sid: dialogue_sid,
93       page_size: limits[:page_size],
94   )
95 
96   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
97 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb
188 def to_s
189   '#<Twilio.Autopilot.V1.QueryList>'
190 end