package dataqna
import "cloud.google.com/go/dataqna/apiv1alpha"
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:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/dataqna/apiv1alpha@latest 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, mentioned above.
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 ¶
- func DefaultAuthScopes() []string
- type AutoSuggestionCallOptions
- type AutoSuggestionClient
- func NewAutoSuggestionClient(ctx context.Context, opts ...option.ClientOption) (*AutoSuggestionClient, error)
- func NewAutoSuggestionRESTClient(ctx context.Context, opts ...option.ClientOption) (*AutoSuggestionClient, error)
- func (c *AutoSuggestionClient) Close() error
- func (c *AutoSuggestionClient) Connection() *grpc.ClientConn
- func (c *AutoSuggestionClient) SuggestQueries(ctx context.Context, req *dataqnapb.SuggestQueriesRequest, opts ...gax.CallOption) (*dataqnapb.SuggestQueriesResponse, error)
- type QuestionCallOptions
- type QuestionClient
- func NewQuestionClient(ctx context.Context, opts ...option.ClientOption) (*QuestionClient, error)
- func NewQuestionRESTClient(ctx context.Context, opts ...option.ClientOption) (*QuestionClient, error)
- func (c *QuestionClient) Close() error
- func (c *QuestionClient) Connection() *grpc.ClientConn
- func (c *QuestionClient) CreateQuestion(ctx context.Context, req *dataqnapb.CreateQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error)
- func (c *QuestionClient) ExecuteQuestion(ctx context.Context, req *dataqnapb.ExecuteQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error)
- func (c *QuestionClient) GetQuestion(ctx context.Context, req *dataqnapb.GetQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error)
- func (c *QuestionClient) GetUserFeedback(ctx context.Context, req *dataqnapb.GetUserFeedbackRequest, opts ...gax.CallOption) (*dataqnapb.UserFeedback, error)
- func (c *QuestionClient) UpdateUserFeedback(ctx context.Context, req *dataqnapb.UpdateUserFeedbackRequest, opts ...gax.CallOption) (*dataqnapb.UserFeedback, error)
Examples ¶
- AutoSuggestionClient.SuggestQueries
- NewAutoSuggestionClient
- NewAutoSuggestionRESTClient
- NewQuestionClient
- NewQuestionRESTClient
- QuestionClient.CreateQuestion
- QuestionClient.ExecuteQuestion
- QuestionClient.GetQuestion
- QuestionClient.GetUserFeedback
- QuestionClient.UpdateUserFeedback
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).
Code:play
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
}
func NewAutoSuggestionRESTClient ¶
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).
Code:play
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
}
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 ¶
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 ¶
func (c *AutoSuggestionClient) SuggestQueries(ctx context.Context, req *dataqnapb.SuggestQueriesRequest, opts ...gax.CallOption) (*dataqnapb.SuggestQueriesResponse, error)
SuggestQueries gets a list of suggestions based on a prefix string.
AutoSuggestion tolerance should be less than 1 second.
Code:play
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
}
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.
Code:play
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
}
func NewQuestionRESTClient ¶
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.
Code:play
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
}
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 ¶
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 ¶
func (c *QuestionClient) CreateQuestion(ctx context.Context, req *dataqnapb.CreateQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error)
CreateQuestion creates a question.
Code:play
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
}
func (*QuestionClient) ExecuteQuestion ¶
func (c *QuestionClient) ExecuteQuestion(ctx context.Context, req *dataqnapb.ExecuteQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error)
ExecuteQuestion executes an interpretation.
Code:play
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
}
func (*QuestionClient) GetQuestion ¶
func (c *QuestionClient) GetQuestion(ctx context.Context, req *dataqnapb.GetQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error)
GetQuestion gets a previously created question.
Code:play
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
}
func (*QuestionClient) GetUserFeedback ¶
func (c *QuestionClient) GetUserFeedback(ctx context.Context, req *dataqnapb.GetUserFeedbackRequest, opts ...gax.CallOption) (*dataqnapb.UserFeedback, error)
GetUserFeedback gets previously created user feedback.
Code:play
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
}
func (*QuestionClient) UpdateUserFeedback ¶
func (c *QuestionClient) UpdateUserFeedback(ctx context.Context, req *dataqnapb.UpdateUserFeedbackRequest, opts ...gax.CallOption) (*dataqnapb.UserFeedback, error)
UpdateUserFeedback updates user feedback. This creates user feedback if there was none before
(upsert).
Code:play
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
}
Source Files ¶
auto_suggestion_client.go auxiliary.go auxiliary_go123.go doc.go helpers.go question_client.go version.go
Directories ¶
Path | Synopsis |
---|---|
apiv1alpha/dataqnapb |
- Version
- v0.9.3 (latest)
- Published
- Jan 2, 2025
- Platform
- linux/amd64
- Imports
- 23 packages
- Last checked
- 5 days ago –
Tools for package owners.