dataqna

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package dataqna is an auto-generated package for the Data QnA API.

Data QnA is a natural language question and answer service for BigQuery data.

NOTE: This package is in alpha. It is not stable, and is likely to change.

General documentation

For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:

Example usage

To get started with this package, create a client.

ctx := context.Background()
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in:
//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := dataqna.NewAutoSuggestionClient(ctx)
if err != nil {
	// TODO: Handle error.
}
defer c.Close()

The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client.

ctx := context.Background()
// 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.
// - It may require specifying regional endpoints when creating the service client as shown in:
//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := dataqna.NewAutoSuggestionClient(ctx)
if err != nil {
	// TODO: Handle error.
}
defer c.Close()

req := &dataqnapb.SuggestQueriesRequest{
	// TODO: Fill request struct fields.
	// See https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha/dataqnapb#SuggestQueriesRequest.
}
resp, err := c.SuggestQueries(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp

Use of Context

The ctx passed to NewAutoSuggestionClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

Types

type AutoSuggestionCallOptions

type AutoSuggestionCallOptions struct {
	SuggestQueries []gax.CallOption
}

AutoSuggestionCallOptions contains the retry settings for each method of AutoSuggestionClient.

type AutoSuggestionClient

type AutoSuggestionClient struct {

	// The call options for this service.
	CallOptions *AutoSuggestionCallOptions
	// contains filtered or unexported fields
}

AutoSuggestionClient is a client for interacting with Data QnA API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

This stateless API provides automatic suggestions for natural language queries for the data sources in the provided project and location.

The service provides a resourceless operation suggestQueries that can be called to get a list of suggestions for a given incomplete query and scope (or list of scopes) under which the query is to be interpreted.

There are two types of suggestions, ENTITY for single entity suggestions and TEMPLATE for full sentences. By default, both types are returned.

Example Request:

The service will retrieve information based on the given scope(s) and give suggestions based on that (e.g. “top item” for “top it” if “item” is a known dimension for the provided scope).

func NewAutoSuggestionClient

func NewAutoSuggestionClient(ctx context.Context, opts ...option.ClientOption) (*AutoSuggestionClient, error)

NewAutoSuggestionClient creates a new auto suggestion service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

This stateless API provides automatic suggestions for natural language queries for the data sources in the provided project and location.

The service provides a resourceless operation suggestQueries that can be called to get a list of suggestions for a given incomplete query and scope (or list of scopes) under which the query is to be interpreted.

There are two types of suggestions, ENTITY for single entity suggestions and TEMPLATE for full sentences. By default, both types are returned.

Example Request:

The service will retrieve information based on the given scope(s) and give suggestions based on that (e.g. “top item” for “top it” if “item” is a known dimension for the provided scope).

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewAutoSuggestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}
Output:

func NewAutoSuggestionRESTClient added in v0.4.0

func NewAutoSuggestionRESTClient(ctx context.Context, opts ...option.ClientOption) (*AutoSuggestionClient, error)

NewAutoSuggestionRESTClient creates a new auto suggestion service rest client.

This stateless API provides automatic suggestions for natural language queries for the data sources in the provided project and location.

The service provides a resourceless operation suggestQueries that can be called to get a list of suggestions for a given incomplete query and scope (or list of scopes) under which the query is to be interpreted.

There are two types of suggestions, ENTITY for single entity suggestions and TEMPLATE for full sentences. By default, both types are returned.

Example Request:

The service will retrieve information based on the given scope(s) and give suggestions based on that (e.g. “top item” for “top it” if “item” is a known dimension for the provided scope).

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewAutoSuggestionRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}
Output:

func (*AutoSuggestionClient) Close

func (c *AutoSuggestionClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*AutoSuggestionClient) Connection deprecated

func (c *AutoSuggestionClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*AutoSuggestionClient) SuggestQueries

SuggestQueries gets a list of suggestions based on a prefix string. AutoSuggestion tolerance should be less than 1 second.

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
	dataqnapb "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewAutoSuggestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataqnapb.SuggestQueriesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha/dataqnapb#SuggestQueriesRequest.
	}
	resp, err := c.SuggestQueries(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

type QuestionCallOptions

type QuestionCallOptions struct {
	GetQuestion        []gax.CallOption
	CreateQuestion     []gax.CallOption
	ExecuteQuestion    []gax.CallOption
	GetUserFeedback    []gax.CallOption
	UpdateUserFeedback []gax.CallOption
}

QuestionCallOptions contains the retry settings for each method of QuestionClient.

type QuestionClient

type QuestionClient struct {

	// The call options for this service.
	CallOptions *QuestionCallOptions
	// contains filtered or unexported fields
}

QuestionClient is a client for interacting with Data QnA API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

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.

func NewQuestionClient

func NewQuestionClient(ctx context.Context, opts ...option.ClientOption) (*QuestionClient, error)

NewQuestionClient creates a new question service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

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.

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewQuestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}
Output:

func NewQuestionRESTClient added in v0.4.0

func NewQuestionRESTClient(ctx context.Context, opts ...option.ClientOption) (*QuestionClient, error)

NewQuestionRESTClient creates a new question service rest client.

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.

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewQuestionRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}
Output:

func (*QuestionClient) Close

func (c *QuestionClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*QuestionClient) Connection deprecated

func (c *QuestionClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*QuestionClient) CreateQuestion

CreateQuestion creates a question.

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
	dataqnapb "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewQuestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataqnapb.CreateQuestionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha/dataqnapb#CreateQuestionRequest.
	}
	resp, err := c.CreateQuestion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*QuestionClient) ExecuteQuestion

ExecuteQuestion executes an interpretation.

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
	dataqnapb "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewQuestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataqnapb.ExecuteQuestionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha/dataqnapb#ExecuteQuestionRequest.
	}
	resp, err := c.ExecuteQuestion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*QuestionClient) GetQuestion

GetQuestion gets a previously created question.

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
	dataqnapb "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewQuestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataqnapb.GetQuestionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha/dataqnapb#GetQuestionRequest.
	}
	resp, err := c.GetQuestion(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*QuestionClient) GetUserFeedback

GetUserFeedback gets previously created user feedback.

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
	dataqnapb "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewQuestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataqnapb.GetUserFeedbackRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha/dataqnapb#GetUserFeedbackRequest.
	}
	resp, err := c.GetUserFeedback(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*QuestionClient) UpdateUserFeedback

UpdateUserFeedback updates user feedback. This creates user feedback if there was none before (upsert).

Example
package main

import (
	"context"

	dataqna "cloud.google.com/go/dataqna/apiv1alpha"
	dataqnapb "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb"
)

func main() {
	ctx := context.Background()
	// 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.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataqna.NewQuestionClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataqnapb.UpdateUserFeedbackRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha/dataqnapb#UpdateUserFeedbackRequest.
	}
	resp, err := c.UpdateUserFeedback(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL