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.
opts
ClientOptions
gaxInstance
typeof gax | typeof gax.fallback
: loaded instance of google-gax
. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new QuestionServiceClient({fallback: 'rest'}, gax); ```
Properties
apiEndpoint
static
get
apiEndpoint
()
:
string
;
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
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.
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.
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.
request
protos. google.cloud.dataqna.v1alpha.ICreateQuestionRequest
The request object that will be sent.
options
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 . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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
;
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
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
;
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
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.
request
protos. google.cloud.dataqna.v1alpha.IExecuteQuestionRequest
The request object that will be sent.
options
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 . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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
;
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
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
;
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
getProjectId()
getProjectId
()
:
Promise<string>
;
Promise
<string>
getProjectId(callback)
getProjectId
(
callback
:
Callback<string
,
undefined
,
undefined
> )
:
void
;
callback
Callback
<string, undefined, undefined>
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.
request
protos. google.cloud.dataqna.v1alpha.IGetQuestionRequest
The request object that will be sent.
options
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 . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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
;
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
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
;
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
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.
request
protos. google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest
The request object that will be sent.
options
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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
;
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
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
;
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
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.
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.
project
string
location
string
string
{string} Resource name string.
matchLocationFromLocationName(locationName)
matchLocationFromLocationName
(
locationName
:
string
)
:
string
|
number
;
Parse the location from Location resource.
locationName
string
A fully-qualified path representing Location resource.
string | number
{string} A string representing the location.
matchLocationFromQuestionName(questionName)
matchLocationFromQuestionName
(
questionName
:
string
)
:
string
|
number
;
Parse the location from Question resource.
questionName
string
A fully-qualified path representing Question resource.
string | number
{string} A string representing the location.
matchLocationFromUserFeedbackName(userFeedbackName)
matchLocationFromUserFeedbackName
(
userFeedbackName
:
string
)
:
string
|
number
;
Parse the location from UserFeedback resource.
userFeedbackName
string
A fully-qualified path representing UserFeedback resource.
string | number
{string} A string representing the location.
matchProjectFromLocationName(locationName)
matchProjectFromLocationName
(
locationName
:
string
)
:
string
|
number
;
Parse the project from Location resource.
locationName
string
A fully-qualified path representing Location resource.
string | number
{string} A string representing the project.
matchProjectFromQuestionName(questionName)
matchProjectFromQuestionName
(
questionName
:
string
)
:
string
|
number
;
Parse the project from Question resource.
questionName
string
A fully-qualified path representing Question resource.
string | number
{string} A string representing the project.
matchProjectFromUserFeedbackName(userFeedbackName)
matchProjectFromUserFeedbackName
(
userFeedbackName
:
string
)
:
string
|
number
;
Parse the project from UserFeedback resource.
userFeedbackName
string
A fully-qualified path representing UserFeedback resource.
string | number
{string} A string representing the project.
matchQuestionFromQuestionName(questionName)
matchQuestionFromQuestionName
(
questionName
:
string
)
:
string
|
number
;
Parse the question from Question resource.
questionName
string
A fully-qualified path representing Question resource.
string | number
{string} A string representing the question.
matchQuestionFromUserFeedbackName(userFeedbackName)
matchQuestionFromUserFeedbackName
(
userFeedbackName
:
string
)
:
string
|
number
;
Parse the question from UserFeedback resource.
userFeedbackName
string
A fully-qualified path representing UserFeedback resource.
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.
project
string
location
string
question
string
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).
request
protos. google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest
The request object that will be sent.
options
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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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
;
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
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
;
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
userFeedbackPath(project, location, question)
userFeedbackPath
(
project
:
string
,
location
:
string
,
question
:
string
)
:
string
;
Return a fully-qualified userFeedback resource name string.
project
string
location
string
question
string
string
{string} Resource name string.

