From bf4378b5b859f7b835946891dbfebfee31c4b123 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 30 Aug 2021 10:04:17 -0700 Subject: [PATCH] chore(all): auto-regenerate gapics (#4695) This is an auto-generated regeneration of the gapic clients by cloud.google.com/go/internal/gapicgen. Once the corresponding genproto PR is submitted, genbot will update this PR with a newer dependency to the newer version of genproto and assign reviewers to this PR. If you have been assigned to review this PR, please: - Ensure that the version of genproto in go.mod has been updated. - Ensure that CI is passing. If it's failing, it requires your manual attention. - Approve and submit this PR if you believe it's ready to ship. Corresponding genproto PR: https://github.com/googleapis/go-genproto/pull/667 Changes: feat(kms): add support for Key Reimport PiperOrigin-RevId: 393749648 Source-Link: https://github.com/googleapis/googleapis/commit/e3d9b11abaec81e1c3c9c7cab1f3bb6fa3990651 feat(osconfig): Update osconfig v1 and v1alpha with WindowsApplication Committer: @coodie PiperOrigin-RevId: 393730900 Source-Link: https://github.com/googleapis/googleapis/commit/69fe13f7ca3ca96f34e042596c11e40bb3277924 fix(datastream): Change a few resource pattern variables from camelCase to snake_case PiperOrigin-RevId: 393705818 Source-Link: https://github.com/googleapis/googleapis/commit/9e99074fc73529d946fca7914deb0d21968f03d8 feat(translate): added v3 proto for online/batch document translation and updated v3beta1 proto for format conversion PiperOrigin-RevId: 393656336 Source-Link: https://github.com/googleapis/googleapis/commit/17d3fb258cc9527ddcf910a72126de3a43fac440 --- datastream/apiv1alpha1/doc.go | 2 +- datastream/go.mod | 2 +- datastream/go.sum | 4 +- go.mod | 2 +- go.sum | 4 +- internal/generated/snippets/go.mod | 2 +- internal/generated/snippets/go.sum | 3 +- .../BatchTranslateDocument/main.go | 53 ++++++ .../TranslateDocument/main.go | 48 ++++++ internal/godocfx/go.sum | 4 +- kms/apiv1/doc.go | 2 +- kms/apiv1/key_management_client.go | 18 +- kms/go.mod | 2 +- kms/go.sum | 4 +- osconfig/apiv1/doc.go | 2 +- osconfig/go.mod | 2 +- osconfig/go.sum | 4 +- translate/apiv3/doc.go | 2 +- translate/apiv3/gapic_metadata.json | 10 ++ translate/apiv3/translation_client.go | 162 ++++++++++++++++-- .../apiv3/translation_client_example_test.go | 45 +++++ translate/go.mod | 2 +- translate/go.sum | 4 +- 23 files changed, 342 insertions(+), 41 deletions(-) create mode 100644 internal/generated/snippets/translate/apiv3/TranslationClient/BatchTranslateDocument/main.go create mode 100644 internal/generated/snippets/translate/apiv3/TranslationClient/TranslateDocument/main.go diff --git a/datastream/apiv1alpha1/doc.go b/datastream/apiv1alpha1/doc.go index 7cf0fe0473f..11d9797085d 100644 --- a/datastream/apiv1alpha1/doc.go +++ b/datastream/apiv1alpha1/doc.go @@ -90,7 +90,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210821" +const versionClient = "20210830" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/datastream/go.mod b/datastream/go.mod index 6f089066614..28f655f9c41 100644 --- a/datastream/go.mod +++ b/datastream/go.mod @@ -6,7 +6,7 @@ require ( cloud.google.com/go v0.93.3 github.com/googleapis/gax-go/v2 v2.0.5 google.golang.org/api v0.54.0 - google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 + google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/datastream/go.sum b/datastream/go.sum index 5bfcfa190f2..2adc0bc17e7 100644 --- a/datastream/go.sum +++ b/datastream/go.sum @@ -474,8 +474,8 @@ google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 h1:XosVttQUxX8erNhEruTu053/VchgYuksoS9Bj/OITjU= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea h1:5eMUso2GVOxypVH1fR4oKgDobrvi4DHctJ4fVk66s/4= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/go.mod b/go.mod index 073c8a74908..5d9ec433521 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( go.opencensus.io v0.23.0 golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a google.golang.org/api v0.54.0 - google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 + google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/go.sum b/go.sum index 85a3c03df8c..9d3c9be78ef 100644 --- a/go.sum +++ b/go.sum @@ -475,8 +475,8 @@ google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 h1:z+ErRPu0+KS02Td3fOAgdX+lnPDh/VyaABEJPD4JRQs= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea h1:5eMUso2GVOxypVH1fR4oKgDobrvi4DHctJ4fVk66s/4= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/internal/generated/snippets/go.mod b/internal/generated/snippets/go.mod index 37e48b80185..42e5c60707a 100644 --- a/internal/generated/snippets/go.mod +++ b/internal/generated/snippets/go.mod @@ -119,7 +119,7 @@ require ( cloud.google.com/go/websecurityscanner v0.1.0 cloud.google.com/go/workflows v0.1.0 google.golang.org/api v0.54.0 - google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 + google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea ) replace cloud.google.com/go/storagetransfer => ../../../storagetransfer diff --git a/internal/generated/snippets/go.sum b/internal/generated/snippets/go.sum index 695f7fb5907..a244aa09550 100644 --- a/internal/generated/snippets/go.sum +++ b/internal/generated/snippets/go.sum @@ -143,8 +143,9 @@ google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210824181836-a4879c3d0e89/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210825212027-de86158e7fda/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210827211047-25e5f791fe06/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 h1:z+ErRPu0+KS02Td3fOAgdX+lnPDh/VyaABEJPD4JRQs= google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea h1:5eMUso2GVOxypVH1fR4oKgDobrvi4DHctJ4fVk66s/4= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/internal/generated/snippets/translate/apiv3/TranslationClient/BatchTranslateDocument/main.go b/internal/generated/snippets/translate/apiv3/TranslationClient/BatchTranslateDocument/main.go new file mode 100644 index 00000000000..b2fbf96e8fc --- /dev/null +++ b/internal/generated/snippets/translate/apiv3/TranslationClient/BatchTranslateDocument/main.go @@ -0,0 +1,53 @@ +// 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START translate_v3_generated_TranslationService_BatchTranslateDocument_sync] + +package main + +import ( + "context" + + translate "cloud.google.com/go/translate/apiv3" + translatepb "google.golang.org/genproto/googleapis/cloud/translate/v3" +) + +func main() { + ctx := context.Background() + c, err := translate.NewTranslationClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &translatepb.BatchTranslateDocumentRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/translate/v3#BatchTranslateDocumentRequest. + } + op, err := c.BatchTranslateDocument(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END translate_v3_generated_TranslationService_BatchTranslateDocument_sync] diff --git a/internal/generated/snippets/translate/apiv3/TranslationClient/TranslateDocument/main.go b/internal/generated/snippets/translate/apiv3/TranslationClient/TranslateDocument/main.go new file mode 100644 index 00000000000..1f45ac6f3bd --- /dev/null +++ b/internal/generated/snippets/translate/apiv3/TranslationClient/TranslateDocument/main.go @@ -0,0 +1,48 @@ +// 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START translate_v3_generated_TranslationService_TranslateDocument_sync] + +package main + +import ( + "context" + + translate "cloud.google.com/go/translate/apiv3" + translatepb "google.golang.org/genproto/googleapis/cloud/translate/v3" +) + +func main() { + ctx := context.Background() + c, err := translate.NewTranslationClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &translatepb.TranslateDocumentRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/translate/v3#TranslateDocumentRequest. + } + resp, err := c.TranslateDocument(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END translate_v3_generated_TranslationService_TranslateDocument_sync] diff --git a/internal/godocfx/go.sum b/internal/godocfx/go.sum index dddea86b88b..d2845802ddc 100644 --- a/internal/godocfx/go.sum +++ b/internal/godocfx/go.sum @@ -298,8 +298,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200827165113-ac2560b5e952/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 h1:z+ErRPu0+KS02Td3fOAgdX+lnPDh/VyaABEJPD4JRQs= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea h1:5eMUso2GVOxypVH1fR4oKgDobrvi4DHctJ4fVk66s/4= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/kms/apiv1/doc.go b/kms/apiv1/doc.go index ce96a86fe61..edcb7873a34 100644 --- a/kms/apiv1/doc.go +++ b/kms/apiv1/doc.go @@ -91,7 +91,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210821" +const versionClient = "20210830" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/kms/apiv1/key_management_client.go b/kms/apiv1/key_management_client.go index 4b83827fcd8..62fe8c5b402 100644 --- a/kms/apiv1/key_management_client.go +++ b/kms/apiv1/key_management_client.go @@ -505,11 +505,12 @@ func (c *KeyManagementClient) CreateCryptoKeyVersion(ctx context.Context, req *k return c.internalClient.CreateCryptoKeyVersion(ctx, req, opts...) } -// ImportCryptoKeyVersion imports a new CryptoKeyVersion into an existing CryptoKey using the -// wrapped key material provided in the request. +// ImportCryptoKeyVersion import wrapped key material into a CryptoKeyVersion. // -// The version ID will be assigned the next sequential id within the -// CryptoKey. +// All requests must specify a CryptoKey. If a CryptoKeyVersion is +// additionally specified in the request, key material will be reimported into +// that version. Otherwise, a new version will be created, and will be +// assigned the next sequential id within the CryptoKey. func (c *KeyManagementClient) ImportCryptoKeyVersion(ctx context.Context, req *kmspb.ImportCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) { return c.internalClient.ImportCryptoKeyVersion(ctx, req, opts...) } @@ -548,10 +549,11 @@ func (c *KeyManagementClient) UpdateCryptoKeyPrimaryVersion(ctx context.Context, // DestroyCryptoKeyVersion schedule a CryptoKeyVersion for destruction. // // Upon calling this method, CryptoKeyVersion.state will be set to -// DESTROY_SCHEDULED -// and destroy_time will be set to a time 24 -// hours in the future, at which point the state -// will be changed to +// DESTROY_SCHEDULED, +// and destroy_time will be set to the time +// destroy_scheduled_duration in the +// future. At that time, the state will +// automatically change to // DESTROYED, and the key // material will be irrevocably destroyed. // diff --git a/kms/go.mod b/kms/go.mod index 76dc91daca5..6ceb9723aee 100644 --- a/kms/go.mod +++ b/kms/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/googleapis/gax-go/v2 v2.0.5 google.golang.org/api v0.54.0 - google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 + google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/kms/go.sum b/kms/go.sum index 5bfcfa190f2..2adc0bc17e7 100644 --- a/kms/go.sum +++ b/kms/go.sum @@ -474,8 +474,8 @@ google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 h1:XosVttQUxX8erNhEruTu053/VchgYuksoS9Bj/OITjU= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea h1:5eMUso2GVOxypVH1fR4oKgDobrvi4DHctJ4fVk66s/4= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/osconfig/apiv1/doc.go b/osconfig/apiv1/doc.go index ebe811ac8f7..bcff5fa2e9d 100644 --- a/osconfig/apiv1/doc.go +++ b/osconfig/apiv1/doc.go @@ -85,7 +85,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210821" +const versionClient = "20210830" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/osconfig/go.mod b/osconfig/go.mod index d634a5f586f..8d945f2e41d 100644 --- a/osconfig/go.mod +++ b/osconfig/go.mod @@ -6,7 +6,7 @@ require ( cloud.google.com/go v0.93.3 github.com/googleapis/gax-go/v2 v2.0.5 google.golang.org/api v0.54.0 - google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 + google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/osconfig/go.sum b/osconfig/go.sum index 5bfcfa190f2..2adc0bc17e7 100644 --- a/osconfig/go.sum +++ b/osconfig/go.sum @@ -474,8 +474,8 @@ google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 h1:XosVttQUxX8erNhEruTu053/VchgYuksoS9Bj/OITjU= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea h1:5eMUso2GVOxypVH1fR4oKgDobrvi4DHctJ4fVk66s/4= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/translate/apiv3/doc.go b/translate/apiv3/doc.go index cce54d38668..e11d5d94c27 100644 --- a/translate/apiv3/doc.go +++ b/translate/apiv3/doc.go @@ -84,7 +84,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210821" +const versionClient = "20210830" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/translate/apiv3/gapic_metadata.json b/translate/apiv3/gapic_metadata.json index cc792ac4728..4608562e63e 100644 --- a/translate/apiv3/gapic_metadata.json +++ b/translate/apiv3/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "TranslationClient", "rpcs": { + "BatchTranslateDocument": { + "methods": [ + "BatchTranslateDocument" + ] + }, "BatchTranslateText": { "methods": [ "BatchTranslateText" @@ -45,6 +50,11 @@ "ListGlossaries" ] }, + "TranslateDocument": { + "methods": [ + "TranslateDocument" + ] + }, "TranslateText": { "methods": [ "TranslateText" diff --git a/translate/apiv3/translation_client.go b/translate/apiv3/translation_client.go index 510d9f01806..4c51ddadfb0 100644 --- a/translate/apiv3/translation_client.go +++ b/translate/apiv3/translation_client.go @@ -42,14 +42,16 @@ var newTranslationClientHook clientHook // TranslationCallOptions contains the retry settings for each method of TranslationClient. type TranslationCallOptions struct { - TranslateText []gax.CallOption - DetectLanguage []gax.CallOption - GetSupportedLanguages []gax.CallOption - BatchTranslateText []gax.CallOption - CreateGlossary []gax.CallOption - ListGlossaries []gax.CallOption - GetGlossary []gax.CallOption - DeleteGlossary []gax.CallOption + TranslateText []gax.CallOption + DetectLanguage []gax.CallOption + GetSupportedLanguages []gax.CallOption + TranslateDocument []gax.CallOption + BatchTranslateText []gax.CallOption + BatchTranslateDocument []gax.CallOption + CreateGlossary []gax.CallOption + ListGlossaries []gax.CallOption + GetGlossary []gax.CallOption + DeleteGlossary []gax.CallOption } func defaultTranslationGRPCClientOptions() []option.ClientOption { @@ -81,8 +83,10 @@ func defaultTranslationCallOptions() *TranslationCallOptions { }) }), }, - BatchTranslateText: []gax.CallOption{}, - CreateGlossary: []gax.CallOption{}, + TranslateDocument: []gax.CallOption{}, + BatchTranslateText: []gax.CallOption{}, + BatchTranslateDocument: []gax.CallOption{}, + CreateGlossary: []gax.CallOption{}, ListGlossaries: []gax.CallOption{ gax.WithRetry(func() gax.Retryer { return gax.OnCodes([]codes.Code{ @@ -130,8 +134,11 @@ type internalTranslationClient interface { TranslateText(context.Context, *translatepb.TranslateTextRequest, ...gax.CallOption) (*translatepb.TranslateTextResponse, error) DetectLanguage(context.Context, *translatepb.DetectLanguageRequest, ...gax.CallOption) (*translatepb.DetectLanguageResponse, error) GetSupportedLanguages(context.Context, *translatepb.GetSupportedLanguagesRequest, ...gax.CallOption) (*translatepb.SupportedLanguages, error) + TranslateDocument(context.Context, *translatepb.TranslateDocumentRequest, ...gax.CallOption) (*translatepb.TranslateDocumentResponse, error) BatchTranslateText(context.Context, *translatepb.BatchTranslateTextRequest, ...gax.CallOption) (*BatchTranslateTextOperation, error) BatchTranslateTextOperation(name string) *BatchTranslateTextOperation + BatchTranslateDocument(context.Context, *translatepb.BatchTranslateDocumentRequest, ...gax.CallOption) (*BatchTranslateDocumentOperation, error) + BatchTranslateDocumentOperation(name string) *BatchTranslateDocumentOperation CreateGlossary(context.Context, *translatepb.CreateGlossaryRequest, ...gax.CallOption) (*CreateGlossaryOperation, error) CreateGlossaryOperation(name string) *CreateGlossaryOperation ListGlossaries(context.Context, *translatepb.ListGlossariesRequest, ...gax.CallOption) *GlossaryIterator @@ -194,6 +201,11 @@ func (c *TranslationClient) GetSupportedLanguages(ctx context.Context, req *tran return c.internalClient.GetSupportedLanguages(ctx, req, opts...) } +// TranslateDocument translates documents in synchronous mode. +func (c *TranslationClient) TranslateDocument(ctx context.Context, req *translatepb.TranslateDocumentRequest, opts ...gax.CallOption) (*translatepb.TranslateDocumentResponse, error) { + return c.internalClient.TranslateDocument(ctx, req, opts...) +} + // BatchTranslateText translates a large volume of text in asynchronous batch mode. // This function provides real-time output as the inputs are being processed. // If caller cancels a request, the partial results (for an input file, it’s @@ -211,6 +223,23 @@ func (c *TranslationClient) BatchTranslateTextOperation(name string) *BatchTrans return c.internalClient.BatchTranslateTextOperation(name) } +// BatchTranslateDocument translates a large volume of document in asynchronous batch mode. +// This function provides real-time output as the inputs are being processed. +// If caller cancels a request, the partial results (for an input file, it’s +// all or nothing) may still be available on the specified output location. +// +// This call returns immediately and you can use +// google.longrunning.Operation.name (at http://google.longrunning.Operation.name) to poll the status of the call. +func (c *TranslationClient) BatchTranslateDocument(ctx context.Context, req *translatepb.BatchTranslateDocumentRequest, opts ...gax.CallOption) (*BatchTranslateDocumentOperation, error) { + return c.internalClient.BatchTranslateDocument(ctx, req, opts...) +} + +// BatchTranslateDocumentOperation returns a new BatchTranslateDocumentOperation from a given name. +// The name must be that of a previously created BatchTranslateDocumentOperation, possibly from a different process. +func (c *TranslationClient) BatchTranslateDocumentOperation(name string) *BatchTranslateDocumentOperation { + return c.internalClient.BatchTranslateDocumentOperation(name) +} + // CreateGlossary creates a glossary and returns the long-running operation. Returns // NOT_FOUND, if the project doesn’t exist. func (c *TranslationClient) CreateGlossary(ctx context.Context, req *translatepb.CreateGlossaryRequest, opts ...gax.CallOption) (*CreateGlossaryOperation, error) { @@ -407,6 +436,27 @@ func (c *translationGRPCClient) GetSupportedLanguages(ctx context.Context, req * return resp, nil } +func (c *translationGRPCClient) TranslateDocument(ctx context.Context, req *translatepb.TranslateDocumentRequest, opts ...gax.CallOption) (*translatepb.TranslateDocumentResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 600000*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).TranslateDocument[0:len((*c.CallOptions).TranslateDocument):len((*c.CallOptions).TranslateDocument)], opts...) + var resp *translatepb.TranslateDocumentResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.translationClient.TranslateDocument(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + func (c *translationGRPCClient) BatchTranslateText(ctx context.Context, req *translatepb.BatchTranslateTextRequest, opts ...gax.CallOption) (*BatchTranslateTextOperation, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) @@ -430,6 +480,29 @@ func (c *translationGRPCClient) BatchTranslateText(ctx context.Context, req *tra }, nil } +func (c *translationGRPCClient) BatchTranslateDocument(ctx context.Context, req *translatepb.BatchTranslateDocumentRequest, opts ...gax.CallOption) (*BatchTranslateDocumentOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 600000*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).BatchTranslateDocument[0:len((*c.CallOptions).BatchTranslateDocument):len((*c.CallOptions).BatchTranslateDocument)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.translationClient.BatchTranslateDocument(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &BatchTranslateDocumentOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, resp), + }, nil +} + func (c *translationGRPCClient) CreateGlossary(ctx context.Context, req *translatepb.CreateGlossaryRequest, opts ...gax.CallOption) (*CreateGlossaryOperation, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) @@ -541,6 +614,75 @@ func (c *translationGRPCClient) DeleteGlossary(ctx context.Context, req *transla }, nil } +// BatchTranslateDocumentOperation manages a long-running operation from BatchTranslateDocument. +type BatchTranslateDocumentOperation struct { + lro *longrunning.Operation +} + +// BatchTranslateDocumentOperation returns a new BatchTranslateDocumentOperation from a given name. +// The name must be that of a previously created BatchTranslateDocumentOperation, possibly from a different process. +func (c *translationGRPCClient) BatchTranslateDocumentOperation(name string) *BatchTranslateDocumentOperation { + return &BatchTranslateDocumentOperation{ + lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *BatchTranslateDocumentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateDocumentResponse, error) { + var resp translatepb.BatchTranslateDocumentResponse + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *BatchTranslateDocumentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*translatepb.BatchTranslateDocumentResponse, error) { + var resp translatepb.BatchTranslateDocumentResponse + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *BatchTranslateDocumentOperation) Metadata() (*translatepb.BatchTranslateDocumentMetadata, error) { + var meta translatepb.BatchTranslateDocumentMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *BatchTranslateDocumentOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *BatchTranslateDocumentOperation) Name() string { + return op.lro.Name() +} + // BatchTranslateTextOperation manages a long-running operation from BatchTranslateText. type BatchTranslateTextOperation struct { lro *longrunning.Operation diff --git a/translate/apiv3/translation_client_example_test.go b/translate/apiv3/translation_client_example_test.go index cc5eacdc72c..2fd8eddaa21 100644 --- a/translate/apiv3/translation_client_example_test.go +++ b/translate/apiv3/translation_client_example_test.go @@ -96,6 +96,26 @@ func ExampleTranslationClient_GetSupportedLanguages() { _ = resp } +func ExampleTranslationClient_TranslateDocument() { + ctx := context.Background() + c, err := translate.NewTranslationClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &translatepb.TranslateDocumentRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/translate/v3#TranslateDocumentRequest. + } + resp, err := c.TranslateDocument(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + func ExampleTranslationClient_BatchTranslateText() { ctx := context.Background() c, err := translate.NewTranslationClient(ctx) @@ -121,6 +141,31 @@ func ExampleTranslationClient_BatchTranslateText() { _ = resp } +func ExampleTranslationClient_BatchTranslateDocument() { + ctx := context.Background() + c, err := translate.NewTranslationClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &translatepb.BatchTranslateDocumentRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/translate/v3#BatchTranslateDocumentRequest. + } + op, err := c.BatchTranslateDocument(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + func ExampleTranslationClient_CreateGlossary() { ctx := context.Background() c, err := translate.NewTranslationClient(ctx) diff --git a/translate/go.mod b/translate/go.mod index e843335952c..90ace568289 100644 --- a/translate/go.mod +++ b/translate/go.mod @@ -8,7 +8,7 @@ require ( github.com/googleapis/gax-go/v2 v2.0.5 golang.org/x/text v0.3.6 google.golang.org/api v0.54.0 - google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 + google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea google.golang.org/grpc v1.40.0 google.golang.org/protobuf v1.27.1 ) diff --git a/translate/go.sum b/translate/go.sum index 5bfcfa190f2..2adc0bc17e7 100644 --- a/translate/go.sum +++ b/translate/go.sum @@ -474,8 +474,8 @@ google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8 h1:XosVttQUxX8erNhEruTu053/VchgYuksoS9Bj/OITjU= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea h1:5eMUso2GVOxypVH1fR4oKgDobrvi4DHctJ4fVk66s/4= +google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=