Navigation Menu

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

Commit

Permalink
feat: add listGlossaries overload (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and chingor13 committed Oct 1, 2019
1 parent e74d2bc commit df828d4
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 27 deletions.
Expand Up @@ -802,6 +802,65 @@ public final ListGlossariesPagedResponse listGlossaries(String parent) {
return listGlossaries(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
*
* <p>Sample code:
*
* <pre><code>
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* String filter = "";
* for (Glossary element : translationServiceClient.listGlossaries(parent, filter).iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param parent Required. The name of the project from which to list all of the glossaries.
* @param filter Optional. Filter specifying constraints of a list operation. Filtering is not
* supported yet, and the parameter currently has no effect. If missing, no filtering is
* performed.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListGlossariesPagedResponse listGlossaries(LocationName parent, String filter) {
ListGlossariesRequest request =
ListGlossariesRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setFilter(filter)
.build();
return listGlossaries(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
*
* <p>Sample code:
*
* <pre><code>
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* String filter = "";
* for (Glossary element : translationServiceClient.listGlossaries(parent.toString(), filter).iterateAll()) {
* // doThingsWith(element);
* }
* }
* </code></pre>
*
* @param parent Required. The name of the project from which to list all of the glossaries.
* @param filter Optional. Filter specifying constraints of a list operation. Filtering is not
* supported yet, and the parameter currently has no effect. If missing, no filtering is
* performed.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListGlossariesPagedResponse listGlossaries(String parent, String filter) {
ListGlossariesRequest request =
ListGlossariesRequest.newBuilder().setParent(parent).setFilter(filter).build();
return listGlossaries(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
Expand Down
Expand Up @@ -270,6 +270,57 @@ public void listGlossariesExceptionTest() throws Exception {
}
}

@Test
@SuppressWarnings("all")
public void listGlossariesTest2() {
String nextPageToken = "";
Glossary glossariesElement = Glossary.newBuilder().build();
List<Glossary> glossaries = Arrays.asList(glossariesElement);
ListGlossariesResponse expectedResponse =
ListGlossariesResponse.newBuilder()
.setNextPageToken(nextPageToken)
.addAllGlossaries(glossaries)
.build();
mockTranslationService.addResponse(expectedResponse);

LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String filter = "filter-1274492040";

ListGlossariesPagedResponse pagedListResponse = client.listGlossaries(parent, filter);

List<Glossary> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getGlossariesList().get(0), resources.get(0));

List<AbstractMessage> actualRequests = mockTranslationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListGlossariesRequest actualRequest = (ListGlossariesRequest) actualRequests.get(0);

Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent()));
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}

@Test
@SuppressWarnings("all")
public void listGlossariesExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockTranslationService.addException(exception);

try {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String filter = "filter-1274492040";

client.listGlossaries(parent, filter);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}

@Test
@SuppressWarnings("all")
public void getGlossaryTest() {
Expand Down
Expand Up @@ -313,7 +313,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
+ "eleteGlossaryResponse\022\014\n\004name\030\001 \001(\t\022/\n\013s"
+ "ubmit_time\030\002 \001(\0132\032.google.protobuf.Times"
+ "tamp\022,\n\010end_time\030\003 \001(\0132\032.google.protobuf"
+ ".Timestamp2\212\020\n\022TranslationService\022\364\001\n\rTr"
+ ".Timestamp2\232\020\n\022TranslationService\022\364\001\n\rTr"
+ "anslateText\0226.google.cloud.translation.v"
+ "3beta1.TranslateTextRequest\0327.google.clo"
+ "ud.translation.v3beta1.TranslateTextResp"
Expand Down Expand Up @@ -346,32 +346,32 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
+ "ation\"|\202\323\344\223\002?\"3/v3beta1/{parent=projects"
+ "/*/locations/*}/glossaries:\010glossary\332A\017p"
+ "arent,glossary\312A\"\n\010Glossary\022\026CreateGloss"
+ "aryMetadata\022\311\001\n\016ListGlossaries\0227.google."
+ "aryMetadata\022\331\001\n\016ListGlossaries\0227.google."
+ "cloud.translation.v3beta1.ListGlossaries"
+ "Request\0328.google.cloud.translation.v3bet"
+ "a1.ListGlossariesResponse\"D\202\323\344\223\0025\0223/v3be"
+ "a1.ListGlossariesResponse\"T\202\323\344\223\0025\0223/v3be"
+ "ta1/{parent=projects/*/locations/*}/glos"
+ "saries\332A\006parent\022\263\001\n\013GetGlossary\0224.google"
+ ".cloud.translation.v3beta1.GetGlossaryRe"
+ "quest\032*.google.cloud.translation.v3beta1"
+ ".Glossary\"B\202\323\344\223\0025\0223/v3beta1/{name=projec"
+ "ts/*/locations/*/glossaries/*}\332A\004name\022\337\001"
+ "\n\016DeleteGlossary\0227.google.cloud.translat"
+ "ion.v3beta1.DeleteGlossaryRequest\032\035.goog"
+ "le.longrunning.Operation\"u\202\323\344\223\0025*3/v3bet"
+ "a1/{name=projects/*/locations/*/glossari"
+ "es/*}\332A\004name\312A0\n\026DeleteGlossaryResponse\022"
+ "\026DeleteGlossaryMetadata\032~\312A\030translate.go"
+ "ogleapis.com\322A`https://www.googleapis.co"
+ "m/auth/cloud-platform,https://www.google"
+ "apis.com/auth/cloud-translationB\361\001\n\"com."
+ "google.cloud.translate.v3beta1B\027Translat"
+ "ionServiceProtoP\001ZGgoogle.golang.org/gen"
+ "proto/googleapis/cloud/translate/v3beta1"
+ ";translate\370\001\001\252\002\036Google.Cloud.Translate.V"
+ "3Beta1\312\002\036Google\\Cloud\\Translate\\V3beta1\352"
+ "\002!Google::Cloud::Translate::V3beta1b\006pro"
+ "to3"
+ "saries\332A\006parent\332A\rparent,filter\022\263\001\n\013GetG"
+ "lossary\0224.google.cloud.translation.v3bet"
+ "a1.GetGlossaryRequest\032*.google.cloud.tra"
+ "nslation.v3beta1.Glossary\"B\202\323\344\223\0025\0223/v3be"
+ "ta1/{name=projects/*/locations/*/glossar"
+ "ies/*}\332A\004name\022\337\001\n\016DeleteGlossary\0227.googl"
+ "e.cloud.translation.v3beta1.DeleteGlossa"
+ "ryRequest\032\035.google.longrunning.Operation"
+ "\"u\202\323\344\223\0025*3/v3beta1/{name=projects/*/loca"
+ "tions/*/glossaries/*}\332A\004name\312A0\n\026DeleteG"
+ "lossaryResponse\022\026DeleteGlossaryMetadata\032"
+ "~\312A\030translate.googleapis.com\322A`https://w"
+ "ww.googleapis.com/auth/cloud-platform,ht"
+ "tps://www.googleapis.com/auth/cloud-tran"
+ "slationB\361\001\n\"com.google.cloud.translate.v"
+ "3beta1B\027TranslationServiceProtoP\001ZGgoogl"
+ "e.golang.org/genproto/googleapis/cloud/t"
+ "ranslate/v3beta1;translate\370\001\001\252\002\036Google.C"
+ "loud.Translate.V3Beta1\312\002\036Google\\Cloud\\Tr"
+ "anslate\\V3beta1\352\002!Google::Cloud::Transla"
+ "te::V3beta1b\006proto3"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
Expand Down
Expand Up @@ -117,6 +117,7 @@ service TranslationService {
get: "/v3beta1/{parent=projects/*/locations/*}/glossaries"
};
option (google.api.method_signature) = "parent";
option (google.api.method_signature) = "parent,filter";
}

// Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
Expand Down
6 changes: 3 additions & 3 deletions synth.metadata
@@ -1,5 +1,5 @@
{
"updateTime": "2019-09-30T22:34:23.535601Z",
"updateTime": "2019-10-01T21:50:19.303013Z",
"sources": [
{
"generator": {
Expand All @@ -12,8 +12,8 @@
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "588bdb668cd362c2c18a4bc87cf478c64c88dabb",
"internalRef": "272063168"
"sha": "2123bcae97debe57e0870fca157cdf21e32bf3fb",
"internalRef": "272289410"
}
},
{
Expand Down

0 comments on commit df828d4

Please sign in to comment.