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

Commit

Permalink
feat(v2beta1): added filter for ListDocuments and ListKnowledgeBases (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
yoshi-automation committed Oct 29, 2020
1 parent b63c458 commit 487e1bf
Show file tree
Hide file tree
Showing 35 changed files with 1,695 additions and 615 deletions.
Expand Up @@ -849,6 +849,79 @@ public final UnaryCallable<UpdateDocumentRequest, Operation> updateDocumentCalla
return stub.updateDocumentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Reloads the specified document from its specified source, content_uri or content. The
* previously loaded content of the document will be deleted. Note: Even when the content of the
* document has not changed, there still may be side effects because of internal implementation
* changes.
*
* <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
* `projects.knowledgeBases.documents`.
*
* <p>Sample code:
*
* <pre><code>
* try (DocumentsClient documentsClient = DocumentsClient.create()) {
* DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
* GcsSource gcsSource = GcsSource.newBuilder().build();
* Document response = documentsClient.reloadDocumentAsync(name, gcsSource).get();
* }
* </code></pre>
*
* @param name Required. The name of the document to reload. Format: `projects/&lt;Project
* ID&gt;/knowledgeBases/&lt;Knowledge Base ID&gt;/documents/&lt;Document ID&gt;`
* @param gcsSource The path for a Cloud Storage source file for reloading document content. If
* not provided, the Document's existing source will be reloaded.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Document, KnowledgeOperationMetadata> reloadDocumentAsync(
DocumentName name, GcsSource gcsSource) {
ReloadDocumentRequest request =
ReloadDocumentRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setGcsSource(gcsSource)
.build();
return reloadDocumentAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Reloads the specified document from its specified source, content_uri or content. The
* previously loaded content of the document will be deleted. Note: Even when the content of the
* document has not changed, there still may be side effects because of internal implementation
* changes.
*
* <p>Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; only use
* `projects.knowledgeBases.documents`.
*
* <p>Sample code:
*
* <pre><code>
* try (DocumentsClient documentsClient = DocumentsClient.create()) {
* DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
* GcsSource gcsSource = GcsSource.newBuilder().build();
* Document response = documentsClient.reloadDocumentAsync(name.toString(), gcsSource).get();
* }
* </code></pre>
*
* @param name Required. The name of the document to reload. Format: `projects/&lt;Project
* ID&gt;/knowledgeBases/&lt;Knowledge Base ID&gt;/documents/&lt;Document ID&gt;`
* @param gcsSource The path for a Cloud Storage source file for reloading document content. If
* not provided, the Document's existing source will be reloaded.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Document, KnowledgeOperationMetadata> reloadDocumentAsync(
String name, GcsSource gcsSource) {
ReloadDocumentRequest request =
ReloadDocumentRequest.newBuilder().setName(name).setGcsSource(gcsSource).build();
return reloadDocumentAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Reloads the specified document from its specified source, content_uri or content. The
Expand Down
Expand Up @@ -939,6 +939,154 @@ public final UnaryCallable<DeleteIntentRequest, Empty> deleteIntentCallable() {
return stub.deleteIntentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Updates/Creates multiple intents in the specified agent.
*
* <p>Operation &lt;response:
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
*
* <p>Sample code:
*
* <pre><code>
* try (IntentsClient intentsClient = IntentsClient.create()) {
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
* String intentBatchUri = "";
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent, intentBatchUri).get();
* }
* </code></pre>
*
* @param parent Required. The name of the agent to update or create intents in. Supported
* formats:
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
* ID&gt;/locations/&lt;Location ID&gt;/agent`
* @param intentBatchUri The URI to a Google Cloud Storage file containing intents to update or
* create. The file format can either be a serialized proto (of IntentBatch type) or JSON
* object. Note: The URI must start with "gs://".
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
AgentName parent, String intentBatchUri) {
BatchUpdateIntentsRequest request =
BatchUpdateIntentsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setIntentBatchUri(intentBatchUri)
.build();
return batchUpdateIntentsAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Updates/Creates multiple intents in the specified agent.
*
* <p>Operation &lt;response:
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
*
* <p>Sample code:
*
* <pre><code>
* try (IntentsClient intentsClient = IntentsClient.create()) {
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
* String intentBatchUri = "";
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent.toString(), intentBatchUri).get();
* }
* </code></pre>
*
* @param parent Required. The name of the agent to update or create intents in. Supported
* formats:
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
* ID&gt;/locations/&lt;Location ID&gt;/agent`
* @param intentBatchUri The URI to a Google Cloud Storage file containing intents to update or
* create. The file format can either be a serialized proto (of IntentBatch type) or JSON
* object. Note: The URI must start with "gs://".
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
String parent, String intentBatchUri) {
BatchUpdateIntentsRequest request =
BatchUpdateIntentsRequest.newBuilder()
.setParent(parent)
.setIntentBatchUri(intentBatchUri)
.build();
return batchUpdateIntentsAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Updates/Creates multiple intents in the specified agent.
*
* <p>Operation &lt;response:
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
*
* <p>Sample code:
*
* <pre><code>
* try (IntentsClient intentsClient = IntentsClient.create()) {
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
* IntentBatch intentBatchInline = IntentBatch.newBuilder().build();
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent, intentBatchInline).get();
* }
* </code></pre>
*
* @param parent Required. The name of the agent to update or create intents in. Supported
* formats:
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
* ID&gt;/locations/&lt;Location ID&gt;/agent`
* @param intentBatchInline The collection of intents to update or create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
AgentName parent, IntentBatch intentBatchInline) {
BatchUpdateIntentsRequest request =
BatchUpdateIntentsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setIntentBatchInline(intentBatchInline)
.build();
return batchUpdateIntentsAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Updates/Creates multiple intents in the specified agent.
*
* <p>Operation &lt;response:
* [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2beta1.BatchUpdateIntentsResponse]&gt;
*
* <p>Sample code:
*
* <pre><code>
* try (IntentsClient intentsClient = IntentsClient.create()) {
* AgentName parent = AgentName.ofProjectAgentName("[PROJECT]");
* IntentBatch intentBatchInline = IntentBatch.newBuilder().build();
* BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(parent.toString(), intentBatchInline).get();
* }
* </code></pre>
*
* @param parent Required. The name of the agent to update or create intents in. Supported
* formats:
* <p>- `projects/&lt;Project ID&gt;/agent` - `projects/&lt;Project
* ID&gt;/locations/&lt;Location ID&gt;/agent`
* @param intentBatchInline The collection of intents to update or create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<BatchUpdateIntentsResponse, Struct> batchUpdateIntentsAsync(
String parent, IntentBatch intentBatchInline) {
BatchUpdateIntentsRequest request =
BatchUpdateIntentsRequest.newBuilder()
.setParent(parent)
.setIntentBatchInline(intentBatchInline)
.build();
return batchUpdateIntentsAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Updates/Creates multiple intents in the specified agent.
Expand Down
Expand Up @@ -302,10 +302,10 @@ public final UnaryCallable<DetectIntentRequest, DetectIntentResponse> detectInte
* BidiStream&lt;StreamingDetectIntentRequest, StreamingDetectIntentResponse&gt; bidiStream =
* sessionsClient.streamingDetectIntentCallable().call();
*
* String session = "";
* SessionName session = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]");
* QueryInput queryInput = QueryInput.newBuilder().build();
* StreamingDetectIntentRequest request = StreamingDetectIntentRequest.newBuilder()
* .setSession(session)
* .setSession(session.toString())
* .setQueryInput(queryInput)
* .build();
* bidiStream.send(request);
Expand Down
Expand Up @@ -111,7 +111,7 @@ public void tearDown() throws Exception {
@Test
@SuppressWarnings("all")
public void getAgentTest() {
String parent2 = "parent21175163357";
ProjectName parent2 = ProjectName.of("[PROJECT]");
String displayName = "displayName1615086568";
String defaultLanguageCode = "defaultLanguageCode856575222";
String timeZone = "timeZone36848094";
Expand All @@ -121,7 +121,7 @@ public void getAgentTest() {
float classificationThreshold = 1.11581064E8F;
Agent expectedResponse =
Agent.newBuilder()
.setParent(parent2)
.setParent(parent2.toString())
.setDisplayName(displayName)
.setDefaultLanguageCode(defaultLanguageCode)
.setTimeZone(timeZone)
Expand Down Expand Up @@ -167,7 +167,7 @@ public void getAgentExceptionTest() throws Exception {
@Test
@SuppressWarnings("all")
public void setAgentTest() {
String parent = "parent-995424086";
ProjectName parent = ProjectName.of("[PROJECT]");
String displayName = "displayName1615086568";
String defaultLanguageCode = "defaultLanguageCode856575222";
String timeZone = "timeZone36848094";
Expand All @@ -177,7 +177,7 @@ public void setAgentTest() {
float classificationThreshold = 1.11581064E8F;
Agent expectedResponse =
Agent.newBuilder()
.setParent(parent)
.setParent(parent.toString())
.setDisplayName(displayName)
.setDefaultLanguageCode(defaultLanguageCode)
.setTimeZone(timeZone)
Expand Down
Expand Up @@ -461,17 +461,17 @@ public void reloadDocumentTest() throws Exception {
mockDocuments.addResponse(resultOperation);

DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
ReloadDocumentRequest request =
ReloadDocumentRequest.newBuilder().setName(name.toString()).build();
GcsSource gcsSource = GcsSource.newBuilder().build();

Document actualResponse = client.reloadDocumentAsync(request).get();
Document actualResponse = client.reloadDocumentAsync(name, gcsSource).get();
Assert.assertEquals(expectedResponse, actualResponse);

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

Assert.assertEquals(name, DocumentName.parse(actualRequest.getName()));
Assert.assertEquals(gcsSource, actualRequest.getGcsSource());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -486,10 +486,9 @@ public void reloadDocumentExceptionTest() throws Exception {

try {
DocumentName name = DocumentName.of("[PROJECT]", "[KNOWLEDGE_BASE]", "[DOCUMENT]");
ReloadDocumentRequest request =
ReloadDocumentRequest.newBuilder().setName(name.toString()).build();
GcsSource gcsSource = GcsSource.newBuilder().build();

client.reloadDocumentAsync(request).get();
client.reloadDocumentAsync(name, gcsSource).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
Expand Down

0 comments on commit 487e1bf

Please sign in to comment.