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

Commit 487e1bf

Browse files
feat(v2beta1): added filter for ListDocuments and ListKnowledgeBases (#341)
* docs: fixed link from SentimentAnalysisResult PiperOrigin-RevId: 336344634 Source-Author: Google APIs <noreply@google.com> Source-Date: Fri Oct 9 12:36:01 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: fd31b1600fc496d6127665d29f095371d985c637 Source-Link: googleapis/googleapis@fd31b16 * docs: fixed link from SentimentAnalysisResult feat: added filter for ListDocuments and ListKnowledgeBases fix!: added REQUIRED annotation for Agent.parent and EntityType.Entity.value fix!: added resource reference for Agent.parent and StreamingDetectIntentRequest.session PiperOrigin-RevId: 336721089 Source-Author: Google APIs <noreply@google.com> Source-Date: Mon Oct 12 12:38:48 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: d616167ada0a7195613efca5b44fe0aa188836d9 Source-Link: googleapis/googleapis@d616167
1 parent b63c458 commit 487e1bf

35 files changed

+1695
-615
lines changed

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/DocumentsClient.java

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,79 @@ public final UnaryCallable<UpdateDocumentRequest, Operation> updateDocumentCalla
849849
return stub.updateDocumentCallable();
850850
}
851851

852+
// AUTO-GENERATED DOCUMENTATION AND METHOD
853+
/**
854+
* Reloads the specified document from its specified source, content_uri or content. The
855+
* previously loaded content of the document will be deleted. Note: Even when the content of the
856+
* document has not changed, there still may be side effects because of internal implementation
857+
* changes.
858+
*
859+
* <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
860+
* `projects.knowledgeBases.documents`.
861+
*
862+
* <p>Sample code:
863+
*
864+
* <pre><code>
865+
* try (DocumentsClient documentsClient = DocumentsClient.create()) {
866+
* DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
867+
* GcsSource gcsSource = GcsSource.newBuilder().build();
868+
* Document response = documentsClient.reloadDocumentAsync(name, gcsSource).get();
869+
* }
870+
* </code></pre>
871+
*
872+
* @param name Required. The name of the document to reload. Format: `projects/&lt;Project
873+
* ID&gt;/knowledgeBases/&lt;Knowledge Base ID&gt;/documents/&lt;Document ID&gt;`
874+
* @param gcsSource The path for a Cloud Storage source file for reloading document content. If
875+
* not provided, the Document's existing source will be reloaded.
876+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
877+
*/
878+
@BetaApi(
879+
"The surface for long-running operations is not stable yet and may change in the future.")
880+
public final OperationFuture<Document, KnowledgeOperationMetadata> reloadDocumentAsync(
881+
DocumentName name, GcsSource gcsSource) {
882+
ReloadDocumentRequest request =
883+
ReloadDocumentRequest.newBuilder()
884+
.setName(name == null ? null : name.toString())
885+
.setGcsSource(gcsSource)
886+
.build();
887+
return reloadDocumentAsync(request);
888+
}
889+
890+
// AUTO-GENERATED DOCUMENTATION AND METHOD
891+
/**
892+
* Reloads the specified document from its specified source, content_uri or content. The
893+
* previously loaded content of the document will be deleted. Note: Even when the content of the
894+
* document has not changed, there still may be side effects because of internal implementation
895+
* changes.
896+
*
897+
* <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
898+
* `projects.knowledgeBases.documents`.
899+
*
900+
* <p>Sample code:
901+
*
902+
* <pre><code>
903+
* try (DocumentsClient documentsClient = DocumentsClient.create()) {
904+
* DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
905+
* GcsSource gcsSource = GcsSource.newBuilder().build();
906+
* Document response = documentsClient.reloadDocumentAsync(name.toString(), gcsSource).get();
907+
* }
908+
* </code></pre>
909+
*
910+
* @param name Required. The name of the document to reload. Format: `projects/&lt;Project
911+
* ID&gt;/knowledgeBases/&lt;Knowledge Base ID&gt;/documents/&lt;Document ID&gt;`
912+
* @param gcsSource The path for a Cloud Storage source file for reloading document content. If
913+
* not provided, the Document's existing source will be reloaded.
914+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
915+
*/
916+
@BetaApi(
917+
"The surface for long-running operations is not stable yet and may change in the future.")
918+
public final OperationFuture<Document, KnowledgeOperationMetadata> reloadDocumentAsync(
919+
String name, GcsSource gcsSource) {
920+
ReloadDocumentRequest request =
921+
ReloadDocumentRequest.newBuilder().setName(name).setGcsSource(gcsSource).build();
922+
return reloadDocumentAsync(request);
923+
}
924+
852925
// AUTO-GENERATED DOCUMENTATION AND METHOD
853926
/**
854927
* Reloads the specified document from its specified source, content_uri or content. The

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,154 @@ public final UnaryCallable<DeleteIntentRequest, Empty> deleteIntentCallable() {
939939
return stub.deleteIntentCallable();
940940
}
941941

942+
// AUTO-GENERATED DOCUMENTATION AND METHOD
943+
/**
944+
* Updates/Creates multiple intents in the specified agent.
945+
*
946+
* <p>Operation &lt;response:
947+
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
948+
*
949+
* <p>Sample code:
950+
*
951+
* <pre><code>
952+
* try (IntentsClient intentsClient = IntentsClient.create()) {
953+
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
954+
* String intentBatchUri = "";
955+
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent, intentBatchUri).get();
956+
* }
957+
* </code></pre>
958+
*
959+
* @param parent Required. The name of the agent to update or create intents in. Supported
960+
* formats:
961+
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
962+
* ID&gt;/locations/&lt;Location ID&gt;/agent`
963+
* @param intentBatchUri The URI to a Google Cloud Storage file containing intents to update or
964+
* create. The file format can either be a serialized proto (of IntentBatch type) or JSON
965+
* object. Note: The URI must start with "gs://".
966+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
967+
*/
968+
@BetaApi(
969+
"The surface for long-running operations is not stable yet and may change in the future.")
970+
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
971+
AgentName parent, String intentBatchUri) {
972+
BatchUpdateIntentsRequest request =
973+
BatchUpdateIntentsRequest.newBuilder()
974+
.setParent(parent == null ? null : parent.toString())
975+
.setIntentBatchUri(intentBatchUri)
976+
.build();
977+
return batchUpdateIntentsAsync(request);
978+
}
979+
980+
// AUTO-GENERATED DOCUMENTATION AND METHOD
981+
/**
982+
* Updates/Creates multiple intents in the specified agent.
983+
*
984+
* <p>Operation &lt;response:
985+
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
986+
*
987+
* <p>Sample code:
988+
*
989+
* <pre><code>
990+
* try (IntentsClient intentsClient = IntentsClient.create()) {
991+
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
992+
* String intentBatchUri = "";
993+
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent.toString(), intentBatchUri).get();
994+
* }
995+
* </code></pre>
996+
*
997+
* @param parent Required. The name of the agent to update or create intents in. Supported
998+
* formats:
999+
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
1000+
* ID&gt;/locations/&lt;Location ID&gt;/agent`
1001+
* @param intentBatchUri The URI to a Google Cloud Storage file containing intents to update or
1002+
* create. The file format can either be a serialized proto (of IntentBatch type) or JSON
1003+
* object. Note: The URI must start with "gs://".
1004+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
1005+
*/
1006+
@BetaApi(
1007+
"The surface for long-running operations is not stable yet and may change in the future.")
1008+
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
1009+
String parent, String intentBatchUri) {
1010+
BatchUpdateIntentsRequest request =
1011+
BatchUpdateIntentsRequest.newBuilder()
1012+
.setParent(parent)
1013+
.setIntentBatchUri(intentBatchUri)
1014+
.build();
1015+
return batchUpdateIntentsAsync(request);
1016+
}
1017+
1018+
// AUTO-GENERATED DOCUMENTATION AND METHOD
1019+
/**
1020+
* Updates/Creates multiple intents in the specified agent.
1021+
*
1022+
* <p>Operation &lt;response:
1023+
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
1024+
*
1025+
* <p>Sample code:
1026+
*
1027+
* <pre><code>
1028+
* try (IntentsClient intentsClient = IntentsClient.create()) {
1029+
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
1030+
* IntentBatch intentBatchInline = IntentBatch.newBuilder().build();
1031+
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent, intentBatchInline).get();
1032+
* }
1033+
* </code></pre>
1034+
*
1035+
* @param parent Required. The name of the agent to update or create intents in. Supported
1036+
* formats:
1037+
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
1038+
* ID&gt;/locations/&lt;Location ID&gt;/agent`
1039+
* @param intentBatchInline The collection of intents to update or create.
1040+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
1041+
*/
1042+
@BetaApi(
1043+
"The surface for long-running operations is not stable yet and may change in the future.")
1044+
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
1045+
AgentName parent, IntentBatch intentBatchInline) {
1046+
BatchUpdateIntentsRequest request =
1047+
BatchUpdateIntentsRequest.newBuilder()
1048+
.setParent(parent == null ? null : parent.toString())
1049+
.setIntentBatchInline(intentBatchInline)
1050+
.build();
1051+
return batchUpdateIntentsAsync(request);
1052+
}
1053+
1054+
// AUTO-GENERATED DOCUMENTATION AND METHOD
1055+
/**
1056+
* Updates/Creates multiple intents in the specified agent.
1057+
*
1058+
* <p>Operation &lt;response:
1059+
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
1060+
*
1061+
* <p>Sample code:
1062+
*
1063+
* <pre><code>
1064+
* try (IntentsClient intentsClient = IntentsClient.create()) {
1065+
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
1066+
* IntentBatch intentBatchInline = IntentBatch.newBuilder().build();
1067+
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent.toString(), intentBatchInline).get();
1068+
* }
1069+
* </code></pre>
1070+
*
1071+
* @param parent Required. The name of the agent to update or create intents in. Supported
1072+
* formats:
1073+
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
1074+
* ID&gt;/locations/&lt;Location ID&gt;/agent`
1075+
* @param intentBatchInline The collection of intents to update or create.
1076+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
1077+
*/
1078+
@BetaApi(
1079+
"The surface for long-running operations is not stable yet and may change in the future.")
1080+
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
1081+
String parent, IntentBatch intentBatchInline) {
1082+
BatchUpdateIntentsRequest request =
1083+
BatchUpdateIntentsRequest.newBuilder()
1084+
.setParent(parent)
1085+
.setIntentBatchInline(intentBatchInline)
1086+
.build();
1087+
return batchUpdateIntentsAsync(request);
1088+
}
1089+
9421090
// AUTO-GENERATED DOCUMENTATION AND METHOD
9431091
/**
9441092
* Updates/Creates multiple intents in the specified agent.

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ public final UnaryCallable<DetectIntentRequest, DetectIntentResponse> detectInte
302302
* BidiStream&lt;StreamingDetectIntentRequest, StreamingDetectIntentResponse&gt; bidiStream =
303303
* sessionsClient.streamingDetectIntentCallable().call();
304304
*
305-
* String session = "";
305+
* SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]");
306306
* QueryInput queryInput = QueryInput.newBuilder().build();
307307
* StreamingDetectIntentRequest request = StreamingDetectIntentRequest.newBuilder()
308-
* .setSession(session)
308+
* .setSession(session.toString())
309309
* .setQueryInput(queryInput)
310310
* .build();
311311
* bidiStream.send(request);

google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/AgentsClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void tearDown() throws Exception {
111111
@Test
112112
@SuppressWarnings("all")
113113
public void getAgentTest() {
114-
String parent2 = "parent21175163357";
114+
ProjectName parent2 = ProjectName.of("[PROJECT]");
115115
String displayName = "displayName1615086568";
116116
String defaultLanguageCode = "defaultLanguageCode856575222";
117117
String timeZone = "timeZone36848094";
@@ -121,7 +121,7 @@ public void getAgentTest() {
121121
float classificationThreshold = 1.11581064E8F;
122122
Agent expectedResponse =
123123
Agent.newBuilder()
124-
.setParent(parent2)
124+
.setParent(parent2.toString())
125125
.setDisplayName(displayName)
126126
.setDefaultLanguageCode(defaultLanguageCode)
127127
.setTimeZone(timeZone)
@@ -167,7 +167,7 @@ public void getAgentExceptionTest() throws Exception {
167167
@Test
168168
@SuppressWarnings("all")
169169
public void setAgentTest() {
170-
String parent = "parent-995424086";
170+
ProjectName parent = ProjectName.of("[PROJECT]");
171171
String displayName = "displayName1615086568";
172172
String defaultLanguageCode = "defaultLanguageCode856575222";
173173
String timeZone = "timeZone36848094";
@@ -177,7 +177,7 @@ public void setAgentTest() {
177177
float classificationThreshold = 1.11581064E8F;
178178
Agent expectedResponse =
179179
Agent.newBuilder()
180-
.setParent(parent)
180+
.setParent(parent.toString())
181181
.setDisplayName(displayName)
182182
.setDefaultLanguageCode(defaultLanguageCode)
183183
.setTimeZone(timeZone)

google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2beta1/DocumentsClientTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,17 @@ public void reloadDocumentTest() throws Exception {
461461
mockDocuments.addResponse(resultOperation);
462462

463463
DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
464-
ReloadDocumentRequest request =
465-
ReloadDocumentRequest.newBuilder().setName(name.toString()).build();
464+
GcsSource gcsSource = GcsSource.newBuilder().build();
466465

467-
Document actualResponse = client.reloadDocumentAsync(request).get();
466+
Document actualResponse = client.reloadDocumentAsync(name, gcsSource).get();
468467
Assert.assertEquals(expectedResponse, actualResponse);
469468

470469
List<AbstractMessage> actualRequests = mockDocuments.getRequests();
471470
Assert.assertEquals(1, actualRequests.size());
472471
ReloadDocumentRequest actualRequest = (ReloadDocumentRequest) actualRequests.get(0);
473472

474473
Assert.assertEquals(name, DocumentName.parse(actualRequest.getName()));
474+
Assert.assertEquals(gcsSource, actualRequest.getGcsSource());
475475
Assert.assertTrue(
476476
channelProvider.isHeaderSent(
477477
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -486,10 +486,9 @@ public void reloadDocumentExceptionTest() throws Exception {
486486

487487
try {
488488
DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
489-
ReloadDocumentRequest request =
490-
ReloadDocumentRequest.newBuilder().setName(name.toString()).build();
489+
GcsSource gcsSource = GcsSource.newBuilder().build();
491490

492-
client.reloadDocumentAsync(request).get();
491+
client.reloadDocumentAsync(name, gcsSource).get();
493492
Assert.fail("No exception raised");
494493
} catch (ExecutionException e) {
495494
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());

0 commit comments

Comments
 (0)