Class v1alpha.QuestionServiceClient (3.1.0)

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-qna

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of QuestionServiceClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof 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: true}, gax); ```

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
TypeDescription
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
NameDescription
request ICreateQuestionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
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.

Example

  /**
   * 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
NameDescription
request ICreateQuestionRequest
options CallOptions
callback Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
NameDescription
request ICreateQuestionRequest
callback Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.ICreateQuestionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
NameDescription
request IExecuteQuestionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
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.

Example

  /**
   * 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
NameDescription
request IExecuteQuestionRequest
options CallOptions
callback Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
NameDescription
request IExecuteQuestionRequest
callback Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IExecuteQuestionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
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
NameDescription
request IGetQuestionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
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.

Example

  /**
   * 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
NameDescription
request IGetQuestionRequest
options CallOptions
callback Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
NameDescription
request IGetQuestionRequest
callback Callback<protos.google.cloud.dataqna.v1alpha.IQuestion, protos.google.cloud.dataqna.v1alpha.IGetQuestionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
NameDescription
request IGetUserFeedbackRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
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.

Example

  /**
   * 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
NameDescription
request IGetUserFeedbackRequest
options CallOptions
callback Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
NameDescription
request IGetUserFeedbackRequest
callback Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IGetUserFeedbackRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
TypeDescription
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
NameDescription
project string
location string
Returns
TypeDescription
string

{string} Resource name string.

matchLocationFromLocationName(locationName)

matchLocationFromLocationName(locationName: string): string | number;

Parse the location from Location resource.

Parameter
NameDescription
locationName string

A fully-qualified path representing Location resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromQuestionName(questionName)

matchLocationFromQuestionName(questionName: string): string | number;

Parse the location from Question resource.

Parameter
NameDescription
questionName string

A fully-qualified path representing Question resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromUserFeedbackName(userFeedbackName)

matchLocationFromUserFeedbackName(userFeedbackName: string): string | number;

Parse the location from UserFeedback resource.

Parameter
NameDescription
userFeedbackName string

A fully-qualified path representing UserFeedback resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchProjectFromLocationName(locationName)

matchProjectFromLocationName(locationName: string): string | number;

Parse the project from Location resource.

Parameter
NameDescription
locationName string

A fully-qualified path representing Location resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromQuestionName(questionName)

matchProjectFromQuestionName(questionName: string): string | number;

Parse the project from Question resource.

Parameter
NameDescription
questionName string

A fully-qualified path representing Question resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromUserFeedbackName(userFeedbackName)

matchProjectFromUserFeedbackName(userFeedbackName: string): string | number;

Parse the project from UserFeedback resource.

Parameter
NameDescription
userFeedbackName string

A fully-qualified path representing UserFeedback resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchQuestionFromQuestionName(questionName)

matchQuestionFromQuestionName(questionName: string): string | number;

Parse the question from Question resource.

Parameter
NameDescription
questionName string

A fully-qualified path representing Question resource.

Returns
TypeDescription
string | number

{string} A string representing the question.

matchQuestionFromUserFeedbackName(userFeedbackName)

matchQuestionFromUserFeedbackName(userFeedbackName: string): string | number;

Parse the question from UserFeedback resource.

Parameter
NameDescription
userFeedbackName string

A fully-qualified path representing UserFeedback resource.

Returns
TypeDescription
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
NameDescription
project string
location string
question string
Returns
TypeDescription
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
NameDescription
request IUpdateUserFeedbackRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
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.

Example

  /**
   * 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
NameDescription
request IUpdateUserFeedbackRequest
options CallOptions
callback Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
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
NameDescription
request IUpdateUserFeedbackRequest
callback Callback<protos.google.cloud.dataqna.v1alpha.IUserFeedback, protos.google.cloud.dataqna.v1alpha.IUpdateUserFeedbackRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

userFeedbackPath(project, location, question)

userFeedbackPath(project: string, location: string, question: string): string;

Return a fully-qualified userFeedback resource name string.

Parameters
NameDescription
project string
location string
question string
Returns
TypeDescription
string

{string} Resource name string.