Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 4f9cc95

Browse files
docs(regen): update sample code to set total timeout, add API client header test
1 parent b66e672 commit 4f9cc95

6 files changed

Lines changed: 57 additions & 25 deletions

File tree

google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@
5151
* <code>
5252
* LanguageServiceSettings.Builder languageServiceSettingsBuilder =
5353
* LanguageServiceSettings.newBuilder();
54-
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
55-
* .setTotalTimeout(Duration.ofSeconds(30));
54+
* languageServiceSettingsBuilder
55+
* .analyzeSentimentSettings()
56+
* .setRetrySettings(
57+
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
58+
* .setTotalTimeout(Duration.ofSeconds(30))
59+
* .build());
5660
* LanguageServiceSettings languageServiceSettings = languageServiceSettingsBuilder.build();
5761
* </code>
5862
* </pre>

google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStubSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@
7272
* <code>
7373
* LanguageServiceStubSettings.Builder languageServiceSettingsBuilder =
7474
* LanguageServiceStubSettings.newBuilder();
75-
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
76-
* .setTotalTimeout(Duration.ofSeconds(30));
75+
* languageServiceSettingsBuilder
76+
* .analyzeSentimentSettings()
77+
* .setRetrySettings(
78+
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
79+
* .setTotalTimeout(Duration.ofSeconds(30))
80+
* .build());
7781
* LanguageServiceStubSettings languageServiceSettings = languageServiceSettingsBuilder.build();
7882
* </code>
7983
* </pre>

google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@
5151
* <code>
5252
* LanguageServiceSettings.Builder languageServiceSettingsBuilder =
5353
* LanguageServiceSettings.newBuilder();
54-
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
55-
* .setTotalTimeout(Duration.ofSeconds(30));
54+
* languageServiceSettingsBuilder
55+
* .analyzeSentimentSettings()
56+
* .setRetrySettings(
57+
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
58+
* .setTotalTimeout(Duration.ofSeconds(30))
59+
* .build());
5660
* LanguageServiceSettings languageServiceSettings = languageServiceSettingsBuilder.build();
5761
* </code>
5862
* </pre>

google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStubSettings.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@
7272
* <code>
7373
* LanguageServiceStubSettings.Builder languageServiceSettingsBuilder =
7474
* LanguageServiceStubSettings.newBuilder();
75-
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
76-
* .setTotalTimeout(Duration.ofSeconds(30));
75+
* languageServiceSettingsBuilder
76+
* .analyzeSentimentSettings()
77+
* .setRetrySettings(
78+
* languageServiceSettingsBuilder.analyzeSentimentSettings().getRetrySettings().toBuilder()
79+
* .setTotalTimeout(Duration.ofSeconds(30))
80+
* .build());
7781
* LanguageServiceStubSettings languageServiceSettings = languageServiceSettingsBuilder.build();
7882
* </code>
7983
* </pre>

google-cloud-language/src/test/java/com/google/cloud/language/v1/LanguageServiceClientTest.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,17 @@ public void analyzeSentimentTest2() {
126126
mockLanguageService.addResponse(expectedResponse);
127127

128128
Document document = Document.newBuilder().build();
129+
EncodingType encodingType = EncodingType.NONE;
129130

130-
AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document);
131+
AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document, encodingType);
131132
Assert.assertEquals(expectedResponse, actualResponse);
132133

133134
List<AbstractMessage> actualRequests = mockLanguageService.getRequests();
134135
Assert.assertEquals(1, actualRequests.size());
135136
AnalyzeSentimentRequest actualRequest = (AnalyzeSentimentRequest) actualRequests.get(0);
136137

137138
Assert.assertEquals(document, actualRequest.getDocument());
139+
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
138140
Assert.assertTrue(
139141
channelProvider.isHeaderSent(
140142
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -149,8 +151,9 @@ public void analyzeSentimentExceptionTest2() throws Exception {
149151

150152
try {
151153
Document document = Document.newBuilder().build();
154+
EncodingType encodingType = EncodingType.NONE;
152155

153-
client.analyzeSentiment(document);
156+
client.analyzeSentiment(document, encodingType);
154157
Assert.fail("No exception raised");
155158
} catch (InvalidArgumentException e) {
156159
// Expected exception
@@ -209,15 +212,17 @@ public void analyzeEntitiesTest2() {
209212
mockLanguageService.addResponse(expectedResponse);
210213

211214
Document document = Document.newBuilder().build();
215+
EncodingType encodingType = EncodingType.NONE;
212216

213-
AnalyzeEntitiesResponse actualResponse = client.analyzeEntities(document);
217+
AnalyzeEntitiesResponse actualResponse = client.analyzeEntities(document, encodingType);
214218
Assert.assertEquals(expectedResponse, actualResponse);
215219

216220
List<AbstractMessage> actualRequests = mockLanguageService.getRequests();
217221
Assert.assertEquals(1, actualRequests.size());
218222
AnalyzeEntitiesRequest actualRequest = (AnalyzeEntitiesRequest) actualRequests.get(0);
219223

220224
Assert.assertEquals(document, actualRequest.getDocument());
225+
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
221226
Assert.assertTrue(
222227
channelProvider.isHeaderSent(
223228
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -232,8 +237,9 @@ public void analyzeEntitiesExceptionTest2() throws Exception {
232237

233238
try {
234239
Document document = Document.newBuilder().build();
240+
EncodingType encodingType = EncodingType.NONE;
235241

236-
client.analyzeEntities(document);
242+
client.analyzeEntities(document, encodingType);
237243
Assert.fail("No exception raised");
238244
} catch (InvalidArgumentException e) {
239245
// Expected exception
@@ -294,8 +300,10 @@ public void analyzeEntitySentimentTest2() {
294300
mockLanguageService.addResponse(expectedResponse);
295301

296302
Document document = Document.newBuilder().build();
303+
EncodingType encodingType = EncodingType.NONE;
297304

298-
AnalyzeEntitySentimentResponse actualResponse = client.analyzeEntitySentiment(document);
305+
AnalyzeEntitySentimentResponse actualResponse =
306+
client.analyzeEntitySentiment(document, encodingType);
299307
Assert.assertEquals(expectedResponse, actualResponse);
300308

301309
List<AbstractMessage> actualRequests = mockLanguageService.getRequests();
@@ -304,6 +312,7 @@ public void analyzeEntitySentimentTest2() {
304312
(AnalyzeEntitySentimentRequest) actualRequests.get(0);
305313

306314
Assert.assertEquals(document, actualRequest.getDocument());
315+
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
307316
Assert.assertTrue(
308317
channelProvider.isHeaderSent(
309318
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -318,8 +327,9 @@ public void analyzeEntitySentimentExceptionTest2() throws Exception {
318327

319328
try {
320329
Document document = Document.newBuilder().build();
330+
EncodingType encodingType = EncodingType.NONE;
321331

322-
client.analyzeEntitySentiment(document);
332+
client.analyzeEntitySentiment(document, encodingType);
323333
Assert.fail("No exception raised");
324334
} catch (InvalidArgumentException e) {
325335
// Expected exception
@@ -378,15 +388,17 @@ public void analyzeSyntaxTest2() {
378388
mockLanguageService.addResponse(expectedResponse);
379389

380390
Document document = Document.newBuilder().build();
391+
EncodingType encodingType = EncodingType.NONE;
381392

382-
AnalyzeSyntaxResponse actualResponse = client.analyzeSyntax(document);
393+
AnalyzeSyntaxResponse actualResponse = client.analyzeSyntax(document, encodingType);
383394
Assert.assertEquals(expectedResponse, actualResponse);
384395

385396
List<AbstractMessage> actualRequests = mockLanguageService.getRequests();
386397
Assert.assertEquals(1, actualRequests.size());
387398
AnalyzeSyntaxRequest actualRequest = (AnalyzeSyntaxRequest) actualRequests.get(0);
388399

389400
Assert.assertEquals(document, actualRequest.getDocument());
401+
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
390402
Assert.assertTrue(
391403
channelProvider.isHeaderSent(
392404
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -401,8 +413,9 @@ public void analyzeSyntaxExceptionTest2() throws Exception {
401413

402414
try {
403415
Document document = Document.newBuilder().build();
416+
EncodingType encodingType = EncodingType.NONE;
404417

405-
client.analyzeSyntax(document);
418+
client.analyzeSyntax(document, encodingType);
406419
Assert.fail("No exception raised");
407420
} catch (InvalidArgumentException e) {
408421
// Expected exception
@@ -503,8 +516,9 @@ public void annotateTextTest2() {
503516

504517
Document document = Document.newBuilder().build();
505518
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
519+
EncodingType encodingType = EncodingType.NONE;
506520

507-
AnnotateTextResponse actualResponse = client.annotateText(document, features);
521+
AnnotateTextResponse actualResponse = client.annotateText(document, features, encodingType);
508522
Assert.assertEquals(expectedResponse, actualResponse);
509523

510524
List<AbstractMessage> actualRequests = mockLanguageService.getRequests();
@@ -513,6 +527,7 @@ public void annotateTextTest2() {
513527

514528
Assert.assertEquals(document, actualRequest.getDocument());
515529
Assert.assertEquals(features, actualRequest.getFeatures());
530+
Assert.assertEquals(encodingType, actualRequest.getEncodingType());
516531
Assert.assertTrue(
517532
channelProvider.isHeaderSent(
518533
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -528,8 +543,9 @@ public void annotateTextExceptionTest2() throws Exception {
528543
try {
529544
Document document = Document.newBuilder().build();
530545
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
546+
EncodingType encodingType = EncodingType.NONE;
531547

532-
client.annotateText(document, features);
548+
client.annotateText(document, features, encodingType);
533549
Assert.fail("No exception raised");
534550
} catch (InvalidArgumentException e) {
535551
// Expected exception

synth.metadata

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
2-
"updateTime": "2020-02-01T08:53:51.262677Z",
2+
"updateTime": "2020-02-08T09:57:20.800454Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.44.4",
8-
"dockerImage": "googleapis/artman@sha256:19e945954fc960a4bdfee6cb34695898ab21a8cf0bac063ee39b91f00a1faec8"
7+
"version": "0.45.0",
8+
"dockerImage": "googleapis/artman@sha256:6aec9c34db0e4be221cdaf6faba27bdc07cfea846808b3d3b964dfce3a9a0f9b"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "b5cbe4a4ba64ab19e6627573ff52057a1657773d",
16-
"internalRef": "292647187",
17-
"log": "b5cbe4a4ba64ab19e6627573ff52057a1657773d\nSecurityCenter v1p1beta1: move file-level option on top to workaround protobuf.js bug.\n\nPiperOrigin-RevId: 292647187\n\nb224b317bf20c6a4fbc5030b4a969c3147f27ad3\nAdds API definitions for bigqueryreservation v1beta1.\n\nPiperOrigin-RevId: 292634722\n\nc1468702f9b17e20dd59007c0804a089b83197d2\nSynchronize new proto/yaml changes.\n\nPiperOrigin-RevId: 292626173\n\nffdfa4f55ab2f0afc11d0eb68f125ccbd5e404bd\nvision: v1p3beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292605599\n\n78f61482cd028fc1d9892aa5d89d768666a954cd\nvision: v1p1beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292605125\n\n60bb5a294a604fd1778c7ec87b265d13a7106171\nvision: v1p2beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292604980\n\n3bcf7aa79d45eb9ec29ab9036e9359ea325a7fc3\nvision: v1p4beta1 publish annotations and retry config\n\nPiperOrigin-RevId: 292604656\n\n2717b8a1c762b26911b45ecc2e4ee01d98401b28\nFix dataproc artman client library generation.\n\nPiperOrigin-RevId: 292555664\n\n"
15+
"sha": "e7d8a694f4559201e6913f6610069cb08b39274e",
16+
"internalRef": "293903652",
17+
"log": "e7d8a694f4559201e6913f6610069cb08b39274e\nDepend on the latest gapic-generator and resource names plugin.\n\nThis fixes the very old an very annoying bug: https://github.com/googleapis/gapic-generator/pull/3087\n\nPiperOrigin-RevId: 293903652\n\n806b2854a966d55374ee26bb0cef4e30eda17b58\nfix: correct capitalization of Ruby namespaces in SecurityCenter V1p1beta1\n\nPiperOrigin-RevId: 293903613\n\n1b83c92462b14d67a7644e2980f723112472e03a\nPublish annotations and grpc service config for Logging API.\n\nPiperOrigin-RevId: 293893514\n\ne46f761cd6ec15a9e3d5ed4ff321a4bcba8e8585\nGenerate the Bazel build file for recommendengine public api\n\nPiperOrigin-RevId: 293710856\n\n68477017c4173c98addac0373950c6aa9d7b375f\nMake `language_code` optional for UpdateIntentRequest and BatchUpdateIntentsRequest.\n\nThe comments and proto annotations describe this parameter as optional.\n\nPiperOrigin-RevId: 293703548\n\n16f823f578bca4e845a19b88bb9bc5870ea71ab2\nAdd BUILD.bazel files for managedidentities API\n\nPiperOrigin-RevId: 293698246\n\n2f53fd8178c9a9de4ad10fae8dd17a7ba36133f2\nAdd v1p1beta1 config file\n\nPiperOrigin-RevId: 293696729\n\n052b274138fce2be80f97b6dcb83ab343c7c8812\nAdd source field for user event and add field behavior annotations\n\nPiperOrigin-RevId: 293693115\n\n1e89732b2d69151b1b3418fff3d4cc0434f0dded\ndatacatalog: v1beta1 add three new RPCs to gapic v1beta1 config\n\nPiperOrigin-RevId: 293692823\n\n9c8bd09bbdc7c4160a44f1fbab279b73cd7a2337\nchange the name of AccessApproval service to AccessApprovalAdmin\n\nPiperOrigin-RevId: 293690934\n\n2e23b8fbc45f5d9e200572ca662fe1271bcd6760\nAdd ListEntryGroups method, add http bindings to support entry group tagging, and update some comments.\n\nPiperOrigin-RevId: 293666452\n\n0275e38a4ca03a13d3f47a9613aac8c8b0d3f1f2\nAdd proto_package field to managedidentities API. It is needed for APIs that still depend on artman generation.\n\nPiperOrigin-RevId: 293643323\n\n4cdfe8278cb6f308106580d70648001c9146e759\nRegenerating public protos for Data Catalog to add new Custom Type Entry feature.\n\nPiperOrigin-RevId: 293614782\n\n45d2a569ab526a1fad3720f95eefb1c7330eaada\nEnable client generation for v1 ManagedIdentities API.\n\nPiperOrigin-RevId: 293515675\n\n2c17086b77e6f3bcf04a1f65758dfb0c3da1568f\nAdd the Actions on Google common types (//google/actions/type/*).\n\nPiperOrigin-RevId: 293478245\n\n781aadb932e64a12fb6ead7cd842698d99588433\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293443396\n\ne2602608c9138c2fca24162720e67f9307c30b95\nDialogflow weekly v2/v2beta1 library update:\n- Documentation updates\nImportant updates are also posted at\nhttps://cloud.google.com/dialogflow/docs/release-notes\n\nPiperOrigin-RevId: 293442964\n\nc8aef82028d06b7992278fa9294c18570dc86c3d\nAdd cc_proto_library and cc_grpc_library targets for Bigtable protos.\n\nAlso fix indentation of cc_grpc_library targets in Spanner and IAM protos.\n\nPiperOrigin-RevId: 293440538\n\ne2faab04f4cb7f9755072330866689b1943a16e9\ncloudtasks: v2 replace non-standard retry params in gapic config v2\n\nPiperOrigin-RevId: 293424055\n\ndfb4097ea628a8470292c6590a4313aee0c675bd\nerrorreporting: v1beta1 add legacy artman config for php\n\nPiperOrigin-RevId: 293423790\n\nb18aed55b45bfe5b62476292c72759e6c3e573c6\nasset: v1p1beta1 updated comment for `page_size` limit.\n\nPiperOrigin-RevId: 293421386\n\nc9ef36b7956d9859a2fc86ad35fcaa16958ab44f\nbazel: Refactor CI build scripts\n\nPiperOrigin-RevId: 293387911\n\na8ed9d921fdddc61d8467bfd7c1668f0ad90435c\nfix: set Ruby module name for OrgPolicy\n\nPiperOrigin-RevId: 293257997\n\n6c7d28509bd8315de8af0889688ee20099594269\nredis: v1beta1 add UpgradeInstance and connect_mode field to Instance\n\nPiperOrigin-RevId: 293242878\n\nae0abed4fcb4c21f5cb67a82349a049524c4ef68\nredis: v1 add connect_mode field to Instance\n\nPiperOrigin-RevId: 293241914\n\n3f7a0d29b28ee9365771da2b66edf7fa2b4e9c56\nAdds service config definition for bigqueryreservation v1beta1\n\nPiperOrigin-RevId: 293234418\n\n0c88168d5ed6fe353a8cf8cbdc6bf084f6bb66a5\naddition of BUILD & configuration for accessapproval v1\n\nPiperOrigin-RevId: 293219198\n\n39bedc2e30f4778ce81193f6ba1fec56107bcfc4\naccessapproval: v1 publish protos\n\nPiperOrigin-RevId: 293167048\n\n69d9945330a5721cd679f17331a78850e2618226\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080182\n\nf6a1a6b417f39694275ca286110bc3c1ca4db0dc\nAdd file-level `Session` resource definition\n\nPiperOrigin-RevId: 293080178\n\n29d40b78e3dc1579b0b209463fbcb76e5767f72a\nExpose managedidentities/v1beta1/ API for client library usage.\n\nPiperOrigin-RevId: 292979741\n\na22129a1fb6e18056d576dfb7717aef74b63734a\nExpose managedidentities/v1/ API for client library usage.\n\nPiperOrigin-RevId: 292968186\n\n"
1818
}
1919
},
2020
{
2121
"template": {
2222
"name": "java_library",
2323
"origin": "synthtool.gcp",
24-
"version": "2019.10.17"
24+
"version": "2020.2.4"
2525
}
2626
}
2727
],

0 commit comments

Comments
 (0)