Service to interpret natural language queries. The service allows to create Question
resources that are interpreted and are filled with one or more interpretations if the question could be interpreted. Once a Question
resource is created and has at least one interpretation, an interpretation can be chosen for execution, which triggers a query to the backend (for BigQuery, it will create a job). Upon successful execution of that interpretation, backend specific information will be returned so that the client can retrieve the results from the backend.
The Question
resources are named projects/* /locations/* /questions/*
.
The Question
resource has a singletion sub-resource UserFeedback
named projects/* /locations/* /questions/* /userFeedback
, which allows access to user feedback. v1alpha
Package
@google-cloud/data-qnaConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of QuestionServiceClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
Properties
apiEndpoint
get apiEndpoint(): string;
The DNS address for this API service.
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
pathTemplates
pathTemplates: {
[name: string]: gax.PathTemplate;
};
port
static get port(): number;
The port for this API service.
questionServiceStub
questionServiceStub?: Promise<{
[name: string]: Function;
}>;
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
universeDomain
get universeDomain(): string;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns | |
---|---|
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
createQuestion(request, options)
createQuestion(request?: protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest, options?: CallOptions): Promise<[
protos.google.cloud.dataqna.v1alpha.IQuestion,
protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | undefined,
{} | undefined
]>;
Creates a question.
Parameters | |
---|---|
Name | Description |
request |
ICreateQuestionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.dataqna.v1alpha.IQuestion,
protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing Question. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the project this data source reference belongs to.
* Example: `projects/foo/locations/bar`
*/
// const parent = 'abc123'
/**
* Required. The question to create.
*/
// const question = {}
// Imports the Dataqna library
const {QuestionServiceClient} = require('@google-cloud/data-qna').v1alpha;
// Instantiates a client
const dataqnaClient = new QuestionServiceClient();
async function callCreateQuestion() {
// Construct request
const request = {
parent,
question,
};
// Run request
const response = await dataqnaClient.createQuestion(request);
console.log(response);
}
callCreateQuestion();
createQuestion(request, options, callback)
createQuestion(request: protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest, options: CallOptions, callback: Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
ICreateQuestionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
createQuestion(request, callback)
createQuestion(request: protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest, callback: Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
ICreateQuestionRequest
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
executeQuestion(request, options)
executeQuestion(request?: protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest, options?: CallOptions): Promise<[
protos.google.cloud.dataqna.v1alpha.IQuestion,
protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | undefined,
{} | undefined
]>;
Executes an interpretation.
Parameters | |
---|---|
Name | Description |
request |
IExecuteQuestionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.dataqna.v1alpha.IQuestion,
protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing Question. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The unique identifier for the question.
* Example: `projects/foo/locations/bar/questions/1234`
*/
// const name = 'abc123'
/**
* Required. Index of the interpretation to execute.
*/
// const interpretationIndex = 1234
// Imports the Dataqna library
const {QuestionServiceClient} = require('@google-cloud/data-qna').v1alpha;
// Instantiates a client
const dataqnaClient = new QuestionServiceClient();
async function callExecuteQuestion() {
// Construct request
const request = {
name,
interpretationIndex,
};
// Run request
const response = await dataqnaClient.executeQuestion(request);
console.log(response);
}
callExecuteQuestion();
executeQuestion(request, options, callback)
executeQuestion(request: protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest, options: CallOptions, callback: Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IExecuteQuestionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
executeQuestion(request, callback)
executeQuestion(request: protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest, callback: Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IExecuteQuestionRequest
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getProjectId()
getProjectId(): Promise<string>;
Returns | |
---|---|
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter | |
---|---|
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Returns | |
---|---|
Type | Description |
void |
getQuestion(request, options)
getQuestion(request?: protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest, options?: CallOptions): Promise<[
protos.google.cloud.dataqna.v1alpha.IQuestion,
protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | undefined,
{} | undefined
]>;
Gets a previously created question.
Parameters | |
---|---|
Name | Description |
request |
IGetQuestionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.dataqna.v1alpha.IQuestion,
protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing Question. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The unique identifier for the question.
* Example: `projects/foo/locations/bar/questions/1234`
*/
// const name = 'abc123'
/**
* The list of fields to be retrieved.
*/
// const readMask = {}
// Imports the Dataqna library
const {QuestionServiceClient} = require('@google-cloud/data-qna').v1alpha;
// Instantiates a client
const dataqnaClient = new QuestionServiceClient();
async function callGetQuestion() {
// Construct request
const request = {
name,
};
// Run request
const response = await dataqnaClient.getQuestion(request);
console.log(response);
}
callGetQuestion();
getQuestion(request, options, callback)
getQuestion(request: protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest, options: CallOptions, callback: Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetQuestionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getQuestion(request, callback)
getQuestion(request: protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest, callback: Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetQuestionRequest
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getUserFeedback(request, options)
getUserFeedback(request?: protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest, options?: CallOptions): Promise<[
protos.google.cloud.dataqna.v1alpha.IUserFeedback,
protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | undefined,
{} | undefined
]>;
Gets previously created user feedback.
Parameters | |
---|---|
Name | Description |
request |
IGetUserFeedbackRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.dataqna.v1alpha.IUserFeedback,
protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The unique identifier for the user feedback.
* User feedback is a singleton resource on a Question.
* Example: `projects/foo/locations/bar/questions/1234/userFeedback`
*/
// const name = 'abc123'
// Imports the Dataqna library
const {QuestionServiceClient} = require('@google-cloud/data-qna').v1alpha;
// Instantiates a client
const dataqnaClient = new QuestionServiceClient();
async function callGetUserFeedback() {
// Construct request
const request = {
name,
};
// Run request
const response = await dataqnaClient.getUserFeedback(request);
console.log(response);
}
callGetUserFeedback();
getUserFeedback(request, options, callback)
getUserFeedback(request: protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest, options: CallOptions, callback: Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetUserFeedbackRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getUserFeedback(request, callback)
getUserFeedback(request: protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest, callback: Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetUserFeedbackRequest
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Returns | |
---|---|
Type | Description |
Promise<{
[name: string]: Function;
}> | {Promise} A promise that resolves to an authenticated service stub. |
locationPath(project, location)
locationPath(project: string, location: string): string;
Return a fully-qualified location resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |
matchLocationFromLocationName(locationName)
matchLocationFromLocationName(locationName: string): string | number;
Parse the location from Location resource.
Parameter | |
---|---|
Name | Description |
locationName |
string
A fully-qualified path representing Location resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the location. |
matchLocationFromQuestionName(questionName)
matchLocationFromQuestionName(questionName: string): string | number;
Parse the location from Question resource.
Parameter | |
---|---|
Name | Description |
questionName |
string
A fully-qualified path representing Question resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the location. |
matchLocationFromUserFeedbackName(userFeedbackName)
matchLocationFromUserFeedbackName(userFeedbackName: string): string | number;
Parse the location from UserFeedback resource.
Parameter | |
---|---|
Name | Description |
userFeedbackName |
string
A fully-qualified path representing UserFeedback resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the location. |
matchProjectFromLocationName(locationName)
matchProjectFromLocationName(locationName: string): string | number;
Parse the project from Location resource.
Parameter | |
---|---|
Name | Description |
locationName |
string
A fully-qualified path representing Location resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the project. |
matchProjectFromQuestionName(questionName)
matchProjectFromQuestionName(questionName: string): string | number;
Parse the project from Question resource.
Parameter | |
---|---|
Name | Description |
questionName |
string
A fully-qualified path representing Question resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the project. |
matchProjectFromUserFeedbackName(userFeedbackName)
matchProjectFromUserFeedbackName(userFeedbackName: string): string | number;
Parse the project from UserFeedback resource.
Parameter | |
---|---|
Name | Description |
userFeedbackName |
string
A fully-qualified path representing UserFeedback resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the project. |
matchQuestionFromQuestionName(questionName)
matchQuestionFromQuestionName(questionName: string): string | number;
Parse the question from Question resource.
Parameter | |
---|---|
Name | Description |
questionName |
string
A fully-qualified path representing Question resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the question. |
matchQuestionFromUserFeedbackName(userFeedbackName)
matchQuestionFromUserFeedbackName(userFeedbackName: string): string | number;
Parse the question from UserFeedback resource.
Parameter | |
---|---|
Name | Description |
userFeedbackName |
string
A fully-qualified path representing UserFeedback resource. |
Returns | |
---|---|
Type | Description |
string | number | {string} A string representing the question. |
questionPath(project, location, question)
questionPath(project: string, location: string, question: string): string;
Return a fully-qualified question resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
question |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |
updateUserFeedback(request, options)
updateUserFeedback(request?: protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest, options?: CallOptions): Promise<[
protos.google.cloud.dataqna.v1alpha.IUserFeedback,
(protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | undefined),
{} | undefined
]>;
Updates user feedback. This creates user feedback if there was none before (upsert).
Parameters | |
---|---|
Name | Description |
request |
IUpdateUserFeedbackRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.cloud.dataqna.v1alpha.IUserFeedback,
(protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | undefined),
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The user feedback to update. This can be called even if there is no
* user feedback so far.
* The feedback's name field is used to identify the user feedback (and the
* corresponding question) to update.
*/
// const userFeedback = {}
/**
* The list of fields to be updated.
*/
// const updateMask = {}
// Imports the Dataqna library
const {QuestionServiceClient} = require('@google-cloud/data-qna').v1alpha;
// Instantiates a client
const dataqnaClient = new QuestionServiceClient();
async function callUpdateUserFeedback() {
// Construct request
const request = {
userFeedback,
};
// Run request
const response = await dataqnaClient.updateUserFeedback(request);
console.log(response);
}
callUpdateUserFeedback();
updateUserFeedback(request, options, callback)
updateUserFeedback(request: protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest, options: CallOptions, callback: Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IUpdateUserFeedbackRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
updateUserFeedback(request, callback)
updateUserFeedback(request: protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest, callback: Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IUpdateUserFeedbackRequest
|
callback |
Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
userFeedbackPath(project, location, question)
userFeedbackPath(project: string, location: string, question: string): string;
Return a fully-qualified userFeedback resource name string.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
question |
string
|
Returns | |
---|---|
Type | Description |
string | {string} Resource name string. |