From 24c5b8f4f45f8cd8b3001b1ca5a8d80e9f3b39d5 Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Thu, 21 Jan 2021 09:15:37 -0700 Subject: [PATCH] feat(dataqna): start generating apiv1alpha (#3586) --- dataqna/apiv1alpha/auto_suggestion_client.go | 172 +++++++++++ .../auto_suggestion_client_example_test.go | 54 ++++ dataqna/apiv1alpha/doc.go | 117 +++++++ dataqna/apiv1alpha/question_client.go | 289 ++++++++++++++++++ .../question_client_example_test.go | 134 ++++++++ internal/.repo-metadata-full.json | 8 + internal/gapicgen/generator/config.go | 8 + 7 files changed, 782 insertions(+) create mode 100644 dataqna/apiv1alpha/auto_suggestion_client.go create mode 100644 dataqna/apiv1alpha/auto_suggestion_client_example_test.go create mode 100644 dataqna/apiv1alpha/doc.go create mode 100644 dataqna/apiv1alpha/question_client.go create mode 100644 dataqna/apiv1alpha/question_client_example_test.go diff --git a/dataqna/apiv1alpha/auto_suggestion_client.go b/dataqna/apiv1alpha/auto_suggestion_client.go new file mode 100644 index 00000000000..2568d20b7b5 --- /dev/null +++ b/dataqna/apiv1alpha/auto_suggestion_client.go @@ -0,0 +1,172 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package dataqna + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + gtransport "google.golang.org/api/transport/grpc" + dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +var newAutoSuggestionClientHook clientHook + +// AutoSuggestionCallOptions contains the retry settings for each method of AutoSuggestionClient. +type AutoSuggestionCallOptions struct { + SuggestQueries []gax.CallOption +} + +func defaultAutoSuggestionClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("dataqna.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("dataqna.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://dataqna.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultAutoSuggestionCallOptions() *AutoSuggestionCallOptions { + return &AutoSuggestionCallOptions{ + SuggestQueries: []gax.CallOption{}, + } +} + +// 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. +type AutoSuggestionClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE + disableDeadlines bool + + // The gRPC API client. + autoSuggestionClient dataqnapb.AutoSuggestionServiceClient + + // The call options for this service. + CallOptions *AutoSuggestionCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewAutoSuggestionClient creates a new auto suggestion service 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). +func NewAutoSuggestionClient(ctx context.Context, opts ...option.ClientOption) (*AutoSuggestionClient, error) { + clientOpts := defaultAutoSuggestionClientOptions() + + if newAutoSuggestionClientHook != nil { + hookOpts, err := newAutoSuggestionClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + disableDeadlines, err := checkDisableDeadlines() + if err != nil { + return nil, err + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &AutoSuggestionClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + CallOptions: defaultAutoSuggestionCallOptions(), + + autoSuggestionClient: dataqnapb.NewAutoSuggestionServiceClient(connPool), + } + c.setGoogleClientInfo() + + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *AutoSuggestionClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *AutoSuggestionClient) Close() error { + return c.connPool.Close() +} + +// setGoogleClientInfo sets the name and version of the application in +// the `x-goog-api-client` header passed on each request. Intended for +// use by Google-written clients. +func (c *AutoSuggestionClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// SuggestQueries gets a list of suggestions based on a prefix string. +// AutoSuggestion tolerance should be less than 1 second. +func (c *AutoSuggestionClient) SuggestQueries(ctx context.Context, req *dataqnapb.SuggestQueriesRequest, opts ...gax.CallOption) (*dataqnapb.SuggestQueriesResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 2000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.SuggestQueries[0:len(c.CallOptions.SuggestQueries):len(c.CallOptions.SuggestQueries)], opts...) + var resp *dataqnapb.SuggestQueriesResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.autoSuggestionClient.SuggestQueries(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/dataqna/apiv1alpha/auto_suggestion_client_example_test.go b/dataqna/apiv1alpha/auto_suggestion_client_example_test.go new file mode 100644 index 00000000000..83e90393afa --- /dev/null +++ b/dataqna/apiv1alpha/auto_suggestion_client_example_test.go @@ -0,0 +1,54 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package dataqna_test + +import ( + "context" + + dataqna "cloud.google.com/go/dataqna/apiv1alpha" + dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" +) + +func ExampleNewAutoSuggestionClient() { + ctx := context.Background() + c, err := dataqna.NewAutoSuggestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleAutoSuggestionClient_SuggestQueries() { + // import dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + + ctx := context.Background() + c, err := dataqna.NewAutoSuggestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &dataqnapb.SuggestQueriesRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.SuggestQueries(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/dataqna/apiv1alpha/doc.go b/dataqna/apiv1alpha/doc.go new file mode 100644 index 00000000000..c97f52736ac --- /dev/null +++ b/dataqna/apiv1alpha/doc.go @@ -0,0 +1,117 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +// 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. +// +// Use of Context +// +// The ctx passed to NewClient 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. +// +// For information about setting deadlines, reusing contexts, and more +// please visit pkg.go.dev/cloud.google.com/go. +package dataqna // import "cloud.google.com/go/dataqna/apiv1alpha" + +import ( + "context" + "os" + "runtime" + "strconv" + "strings" + "unicode" + + "google.golang.org/api/option" + "google.golang.org/grpc/metadata" +) + +// For more information on implementing a client constructor hook, see +// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. +type clientHookParams struct{} +type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) + +const versionClient = "20210120" + +func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { + out, _ := metadata.FromOutgoingContext(ctx) + out = out.Copy() + for _, md := range mds { + for k, v := range md { + out[k] = append(out[k], v...) + } + } + return metadata.NewOutgoingContext(ctx, out) +} + +func checkDisableDeadlines() (bool, error) { + raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") + if !ok { + return false, nil + } + + b, err := strconv.ParseBool(raw) + return b, err +} + +// DefaultAuthScopes reports the default set of authentication scopes to use with this package. +func DefaultAuthScopes() []string { + return []string{ + "https://www.googleapis.com/auth/cloud-platform", + } +} + +// versionGo returns the Go runtime version. The returned string +// has no whitespace, suitable for reporting in header. +func versionGo() string { + const develPrefix = "devel +" + + s := runtime.Version() + if strings.HasPrefix(s, develPrefix) { + s = s[len(develPrefix):] + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + return s + } + + notSemverRune := func(r rune) bool { + return !strings.ContainsRune("0123456789.", r) + } + + if strings.HasPrefix(s, "go1") { + s = s[2:] + var prerelease string + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { + s, prerelease = s[:p], s[p:] + } + if strings.HasSuffix(s, ".") { + s += "0" + } else if strings.Count(s, ".") < 2 { + s += ".0" + } + if prerelease != "" { + s += "-" + prerelease + } + return s + } + return "UNKNOWN" +} diff --git a/dataqna/apiv1alpha/question_client.go b/dataqna/apiv1alpha/question_client.go new file mode 100644 index 00000000000..9639756cfaa --- /dev/null +++ b/dataqna/apiv1alpha/question_client.go @@ -0,0 +1,289 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package dataqna + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + gtransport "google.golang.org/api/transport/grpc" + dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newQuestionClientHook clientHook + +// QuestionCallOptions contains the retry settings for each method of QuestionClient. +type QuestionCallOptions struct { + GetQuestion []gax.CallOption + CreateQuestion []gax.CallOption + ExecuteQuestion []gax.CallOption + GetUserFeedback []gax.CallOption + UpdateUserFeedback []gax.CallOption +} + +func defaultQuestionClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("dataqna.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("dataqna.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://dataqna.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultQuestionCallOptions() *QuestionCallOptions { + return &QuestionCallOptions{ + GetQuestion: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateQuestion: []gax.CallOption{}, + ExecuteQuestion: []gax.CallOption{}, + GetUserFeedback: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateUserFeedback: []gax.CallOption{}, + } +} + +// 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. +type QuestionClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE + disableDeadlines bool + + // The gRPC API client. + questionClient dataqnapb.QuestionServiceClient + + // The call options for this service. + CallOptions *QuestionCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewQuestionClient creates a new question service 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. +func NewQuestionClient(ctx context.Context, opts ...option.ClientOption) (*QuestionClient, error) { + clientOpts := defaultQuestionClientOptions() + + if newQuestionClientHook != nil { + hookOpts, err := newQuestionClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + disableDeadlines, err := checkDisableDeadlines() + if err != nil { + return nil, err + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &QuestionClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + CallOptions: defaultQuestionCallOptions(), + + questionClient: dataqnapb.NewQuestionServiceClient(connPool), + } + c.setGoogleClientInfo() + + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *QuestionClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *QuestionClient) Close() error { + return c.connPool.Close() +} + +// setGoogleClientInfo sets the name and version of the application in +// the `x-goog-api-client` header passed on each request. Intended for +// use by Google-written clients. +func (c *QuestionClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// GetQuestion gets a previously created question. +func (c *QuestionClient) GetQuestion(ctx context.Context, req *dataqnapb.GetQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetQuestion[0:len(c.CallOptions.GetQuestion):len(c.CallOptions.GetQuestion)], opts...) + var resp *dataqnapb.Question + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.questionClient.GetQuestion(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateQuestion creates a question. +func (c *QuestionClient) CreateQuestion(ctx context.Context, req *dataqnapb.CreateQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateQuestion[0:len(c.CallOptions.CreateQuestion):len(c.CallOptions.CreateQuestion)], opts...) + var resp *dataqnapb.Question + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.questionClient.CreateQuestion(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ExecuteQuestion executes an interpretation. +func (c *QuestionClient) ExecuteQuestion(ctx context.Context, req *dataqnapb.ExecuteQuestionRequest, opts ...gax.CallOption) (*dataqnapb.Question, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ExecuteQuestion[0:len(c.CallOptions.ExecuteQuestion):len(c.CallOptions.ExecuteQuestion)], opts...) + var resp *dataqnapb.Question + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.questionClient.ExecuteQuestion(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetUserFeedback gets previously created user feedback. +func (c *QuestionClient) GetUserFeedback(ctx context.Context, req *dataqnapb.GetUserFeedbackRequest, opts ...gax.CallOption) (*dataqnapb.UserFeedback, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetUserFeedback[0:len(c.CallOptions.GetUserFeedback):len(c.CallOptions.GetUserFeedback)], opts...) + var resp *dataqnapb.UserFeedback + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.questionClient.GetUserFeedback(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateUserFeedback updates user feedback. This creates user feedback if there was none before +// (upsert). +func (c *QuestionClient) UpdateUserFeedback(ctx context.Context, req *dataqnapb.UpdateUserFeedbackRequest, opts ...gax.CallOption) (*dataqnapb.UserFeedback, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "user_feedback.name", url.QueryEscape(req.GetUserFeedback().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateUserFeedback[0:len(c.CallOptions.UpdateUserFeedback):len(c.CallOptions.UpdateUserFeedback)], opts...) + var resp *dataqnapb.UserFeedback + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.questionClient.UpdateUserFeedback(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/dataqna/apiv1alpha/question_client_example_test.go b/dataqna/apiv1alpha/question_client_example_test.go new file mode 100644 index 00000000000..40112dbcdc6 --- /dev/null +++ b/dataqna/apiv1alpha/question_client_example_test.go @@ -0,0 +1,134 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package dataqna_test + +import ( + "context" + + dataqna "cloud.google.com/go/dataqna/apiv1alpha" + dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" +) + +func ExampleNewQuestionClient() { + ctx := context.Background() + c, err := dataqna.NewQuestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleQuestionClient_GetQuestion() { + // import dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + + ctx := context.Background() + c, err := dataqna.NewQuestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &dataqnapb.GetQuestionRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetQuestion(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleQuestionClient_CreateQuestion() { + // import dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + + ctx := context.Background() + c, err := dataqna.NewQuestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &dataqnapb.CreateQuestionRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.CreateQuestion(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleQuestionClient_ExecuteQuestion() { + // import dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + + ctx := context.Background() + c, err := dataqna.NewQuestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &dataqnapb.ExecuteQuestionRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ExecuteQuestion(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleQuestionClient_GetUserFeedback() { + // import dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + + ctx := context.Background() + c, err := dataqna.NewQuestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &dataqnapb.GetUserFeedbackRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetUserFeedback(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleQuestionClient_UpdateUserFeedback() { + // import dataqnapb "google.golang.org/genproto/googleapis/cloud/dataqna/v1alpha" + + ctx := context.Background() + c, err := dataqna.NewQuestionClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &dataqnapb.UpdateUserFeedbackRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateUserFeedback(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/internal/.repo-metadata-full.json b/internal/.repo-metadata-full.json index 228fdf818e0..c8fcf69377e 100644 --- a/internal/.repo-metadata-full.json +++ b/internal/.repo-metadata-full.json @@ -311,6 +311,14 @@ "docs_url": "https://pkg.go.dev/cloud.google.com/go/dataproc/apiv1beta2", "release_level": "beta" }, + "cloud.google.com/go/dataqna/apiv1alpha": { + "distribution_name": "cloud.google.com/go/dataqna/apiv1alpha", + "description": "Data QnA API", + "language": "Go", + "client_library_type": "generated", + "docs_url": "https://pkg.go.dev/cloud.google.com/go/dataqna/apiv1alpha", + "release_level": "alpha" + }, "cloud.google.com/go/datastore": { "distribution_name": "cloud.google.com/go/datastore", "description": "Cloud Datastore", diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index 0abe11e99f7..635092dc504 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -924,6 +924,14 @@ var microgenGapicConfigs = []*microgenConfig{ apiServiceConfigPath: "google/cloud/datalabeling/v1beta1/datalabeling_v1beta1.yaml", releaseLevel: "beta", }, + { + inputDirectoryPath: "google/cloud/dataqna/v1alpha", + pkg: "dataqna", + importPath: "cloud.google.com/go/dataqna/apiv1alpha", + gRPCServiceConfigPath: "google/cloud/dataqna/v1alpha/dataqna_grpc_service_config.json", + apiServiceConfigPath: "google/cloud/dataqna/v1alpha/dataqna_v1alpha.yaml", + releaseLevel: "alpha", + }, // Non-Cloud APIs {