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

Commit df828d4

Browse files
yoshi-automationchingor13
authored andcommitted
feat: add listGlossaries overload (#8)
1 parent e74d2bc commit df828d4

File tree

5 files changed

+138
-27
lines changed

5 files changed

+138
-27
lines changed

google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,65 @@ public final ListGlossariesPagedResponse listGlossaries(String parent) {
802802
return listGlossaries(request);
803803
}
804804

805+
// AUTO-GENERATED DOCUMENTATION AND METHOD
806+
/**
807+
* Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
808+
*
809+
* <p>Sample code:
810+
*
811+
* <pre><code>
812+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
813+
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
814+
* String filter = "";
815+
* for (Glossary element : translationServiceClient.listGlossaries(parent, filter).iterateAll()) {
816+
* // doThingsWith(element);
817+
* }
818+
* }
819+
* </code></pre>
820+
*
821+
* @param parent Required. The name of the project from which to list all of the glossaries.
822+
* @param filter Optional. Filter specifying constraints of a list operation. Filtering is not
823+
* supported yet, and the parameter currently has no effect. If missing, no filtering is
824+
* performed.
825+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
826+
*/
827+
public final ListGlossariesPagedResponse listGlossaries(LocationName parent, String filter) {
828+
ListGlossariesRequest request =
829+
ListGlossariesRequest.newBuilder()
830+
.setParent(parent == null ? null : parent.toString())
831+
.setFilter(filter)
832+
.build();
833+
return listGlossaries(request);
834+
}
835+
836+
// AUTO-GENERATED DOCUMENTATION AND METHOD
837+
/**
838+
* Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
839+
*
840+
* <p>Sample code:
841+
*
842+
* <pre><code>
843+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
844+
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
845+
* String filter = "";
846+
* for (Glossary element : translationServiceClient.listGlossaries(parent.toString(), filter).iterateAll()) {
847+
* // doThingsWith(element);
848+
* }
849+
* }
850+
* </code></pre>
851+
*
852+
* @param parent Required. The name of the project from which to list all of the glossaries.
853+
* @param filter Optional. Filter specifying constraints of a list operation. Filtering is not
854+
* supported yet, and the parameter currently has no effect. If missing, no filtering is
855+
* performed.
856+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
857+
*/
858+
public final ListGlossariesPagedResponse listGlossaries(String parent, String filter) {
859+
ListGlossariesRequest request =
860+
ListGlossariesRequest.newBuilder().setParent(parent).setFilter(filter).build();
861+
return listGlossaries(request);
862+
}
863+
805864
// AUTO-GENERATED DOCUMENTATION AND METHOD
806865
/**
807866
* Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

google-cloud-translate/src/test/java/com/google/cloud/translate/v3beta1/TranslationServiceClientTest.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,57 @@ public void listGlossariesExceptionTest() throws Exception {
270270
}
271271
}
272272

273+
@Test
274+
@SuppressWarnings("all")
275+
public void listGlossariesTest2() {
276+
String nextPageToken = "";
277+
Glossary glossariesElement = Glossary.newBuilder().build();
278+
List<Glossary> glossaries = Arrays.asList(glossariesElement);
279+
ListGlossariesResponse expectedResponse =
280+
ListGlossariesResponse.newBuilder()
281+
.setNextPageToken(nextPageToken)
282+
.addAllGlossaries(glossaries)
283+
.build();
284+
mockTranslationService.addResponse(expectedResponse);
285+
286+
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
287+
String filter = "filter-1274492040";
288+
289+
ListGlossariesPagedResponse pagedListResponse = client.listGlossaries(parent, filter);
290+
291+
List<Glossary> resources = Lists.newArrayList(pagedListResponse.iterateAll());
292+
Assert.assertEquals(1, resources.size());
293+
Assert.assertEquals(expectedResponse.getGlossariesList().get(0), resources.get(0));
294+
295+
List<AbstractMessage> actualRequests = mockTranslationService.getRequests();
296+
Assert.assertEquals(1, actualRequests.size());
297+
ListGlossariesRequest actualRequest = (ListGlossariesRequest) actualRequests.get(0);
298+
299+
Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent()));
300+
Assert.assertEquals(filter, actualRequest.getFilter());
301+
Assert.assertTrue(
302+
channelProvider.isHeaderSent(
303+
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
304+
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
305+
}
306+
307+
@Test
308+
@SuppressWarnings("all")
309+
public void listGlossariesExceptionTest2() throws Exception {
310+
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
311+
mockTranslationService.addException(exception);
312+
313+
try {
314+
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
315+
String filter = "filter-1274492040";
316+
317+
client.listGlossaries(parent, filter);
318+
Assert.fail("No exception raised");
319+
} catch (InvalidArgumentException e) {
320+
// Expected exception
321+
}
322+
}
323+
273324
@Test
274325
@SuppressWarnings("all")
275326
public void getGlossaryTest() {

proto-google-cloud-translate-v3beta1/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceProto.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
313313
+ "eleteGlossaryResponse\022\014\n\004name\030\001 \001(\t\022/\n\013s"
314314
+ "ubmit_time\030\002 \001(\0132\032.google.protobuf.Times"
315315
+ "tamp\022,\n\010end_time\030\003 \001(\0132\032.google.protobuf"
316-
+ ".Timestamp2\212\020\n\022TranslationService\022\364\001\n\rTr"
316+
+ ".Timestamp2\232\020\n\022TranslationService\022\364\001\n\rTr"
317317
+ "anslateText\0226.google.cloud.translation.v"
318318
+ "3beta1.TranslateTextRequest\0327.google.clo"
319319
+ "ud.translation.v3beta1.TranslateTextResp"
@@ -346,32 +346,32 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
346346
+ "ation\"|\202\323\344\223\002?\"3/v3beta1/{parent=projects"
347347
+ "/*/locations/*}/glossaries:\010glossary\332A\017p"
348348
+ "arent,glossary\312A\"\n\010Glossary\022\026CreateGloss"
349-
+ "aryMetadata\022\311\001\n\016ListGlossaries\0227.google."
349+
+ "aryMetadata\022\331\001\n\016ListGlossaries\0227.google."
350350
+ "cloud.translation.v3beta1.ListGlossaries"
351351
+ "Request\0328.google.cloud.translation.v3bet"
352-
+ "a1.ListGlossariesResponse\"D\202\323\344\223\0025\0223/v3be"
352+
+ "a1.ListGlossariesResponse\"T\202\323\344\223\0025\0223/v3be"
353353
+ "ta1/{parent=projects/*/locations/*}/glos"
354-
+ "saries\332A\006parent\022\263\001\n\013GetGlossary\0224.google"
355-
+ ".cloud.translation.v3beta1.GetGlossaryRe"
356-
+ "quest\032*.google.cloud.translation.v3beta1"
357-
+ ".Glossary\"B\202\323\344\223\0025\0223/v3beta1/{name=projec"
358-
+ "ts/*/locations/*/glossaries/*}\332A\004name\022\337\001"
359-
+ "\n\016DeleteGlossary\0227.google.cloud.translat"
360-
+ "ion.v3beta1.DeleteGlossaryRequest\032\035.goog"
361-
+ "le.longrunning.Operation\"u\202\323\344\223\0025*3/v3bet"
362-
+ "a1/{name=projects/*/locations/*/glossari"
363-
+ "es/*}\332A\004name\312A0\n\026DeleteGlossaryResponse\022"
364-
+ "\026DeleteGlossaryMetadata\032~\312A\030translate.go"
365-
+ "ogleapis.com\322A`https://www.googleapis.co"
366-
+ "m/auth/cloud-platform,https://www.google"
367-
+ "apis.com/auth/cloud-translationB\361\001\n\"com."
368-
+ "google.cloud.translate.v3beta1B\027Translat"
369-
+ "ionServiceProtoP\001ZGgoogle.golang.org/gen"
370-
+ "proto/googleapis/cloud/translate/v3beta1"
371-
+ ";translate\370\001\001\252\002\036Google.Cloud.Translate.V"
372-
+ "3Beta1\312\002\036Google\\Cloud\\Translate\\V3beta1\352"
373-
+ "\002!Google::Cloud::Translate::V3beta1b\006pro"
374-
+ "to3"
354+
+ "saries\332A\006parent\332A\rparent,filter\022\263\001\n\013GetG"
355+
+ "lossary\0224.google.cloud.translation.v3bet"
356+
+ "a1.GetGlossaryRequest\032*.google.cloud.tra"
357+
+ "nslation.v3beta1.Glossary\"B\202\323\344\223\0025\0223/v3be"
358+
+ "ta1/{name=projects/*/locations/*/glossar"
359+
+ "ies/*}\332A\004name\022\337\001\n\016DeleteGlossary\0227.googl"
360+
+ "e.cloud.translation.v3beta1.DeleteGlossa"
361+
+ "ryRequest\032\035.google.longrunning.Operation"
362+
+ "\"u\202\323\344\223\0025*3/v3beta1/{name=projects/*/loca"
363+
+ "tions/*/glossaries/*}\332A\004name\312A0\n\026DeleteG"
364+
+ "lossaryResponse\022\026DeleteGlossaryMetadata\032"
365+
+ "~\312A\030translate.googleapis.com\322A`https://w"
366+
+ "ww.googleapis.com/auth/cloud-platform,ht"
367+
+ "tps://www.googleapis.com/auth/cloud-tran"
368+
+ "slationB\361\001\n\"com.google.cloud.translate.v"
369+
+ "3beta1B\027TranslationServiceProtoP\001ZGgoogl"
370+
+ "e.golang.org/genproto/googleapis/cloud/t"
371+
+ "ranslate/v3beta1;translate\370\001\001\252\002\036Google.C"
372+
+ "loud.Translate.V3Beta1\312\002\036Google\\Cloud\\Tr"
373+
+ "anslate\\V3beta1\352\002!Google::Cloud::Transla"
374+
+ "te::V3beta1b\006proto3"
375375
};
376376
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
377377
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {

proto-google-cloud-translate-v3beta1/src/main/proto/google/cloud/translate/v3beta1/translation_service.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ service TranslationService {
117117
get: "/v3beta1/{parent=projects/*/locations/*}/glossaries"
118118
};
119119
option (google.api.method_signature) = "parent";
120+
option (google.api.method_signature) = "parent,filter";
120121
}
121122

122123
// Gets a glossary. Returns NOT_FOUND, if the glossary doesn't

synth.metadata

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"updateTime": "2019-09-30T22:34:23.535601Z",
2+
"updateTime": "2019-10-01T21:50:19.303013Z",
33
"sources": [
44
{
55
"generator": {
@@ -12,8 +12,8 @@
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "588bdb668cd362c2c18a4bc87cf478c64c88dabb",
16-
"internalRef": "272063168"
15+
"sha": "2123bcae97debe57e0870fca157cdf21e32bf3fb",
16+
"internalRef": "272289410"
1717
}
1818
},
1919
{

0 commit comments

Comments
 (0)