From 25d4814c7924e77305b1394ee5ff21509b87b865 Mon Sep 17 00:00:00 2001 From: Neo Wu Date: Fri, 13 Apr 2018 15:07:17 -0700 Subject: [PATCH] add dialogflow v2 and batch refresh --- .../v1/DataTransferServiceClient.java | 2 +- .../v1/DataTransferServiceSettings.java | 1 + .../v1/stub/DataTransferServiceStub.java | 3 + .../stub/DataTransferServiceStubSettings.java | 1 + .../v1/stub/GrpcDataTransferServiceStub.java | 2 +- .../data/v2/BaseBigtableDataClient.java | 2 +- .../data/v2/BaseBigtableDataSettings.java | 1 + .../bigtable/data/v2/stub/BigtableStub.java | 3 + .../data/v2/stub/BigtableStubSettings.java | 1 + .../data/v2/stub/GrpcBigtableStub.java | 2 +- google-cloud-bom/pom.xml | 14 +- .../container/v1/ClusterManagerClient.java | 2 +- .../container/v1/ClusterManagerSettings.java | 1 + .../container/v1/stub/ClusterManagerStub.java | 3 + .../v1/stub/ClusterManagerStubSettings.java | 1 + .../v1/stub/GrpcClusterManagerStub.java | 2 +- .../dataproc/v1/ClusterControllerClient.java | 2 +- .../v1/ClusterControllerSettings.java | 1 + .../dataproc/v1/JobControllerClient.java | 2 +- .../dataproc/v1/JobControllerSettings.java | 1 + .../v1/stub/ClusterControllerStub.java | 3 + .../stub/ClusterControllerStubSettings.java | 1 + .../v1/stub/GrpcClusterControllerStub.java | 2 +- .../v1/stub/GrpcJobControllerStub.java | 2 +- .../dataproc/v1/stub/JobControllerStub.java | 3 + .../v1/stub/JobControllerStubSettings.java | 1 + google-cloud-dialogflow/pom.xml | 13 +- .../cloud/dialogflow/v2/AgentsClient.java | 981 +++++++++ .../cloud/dialogflow/v2/AgentsSettings.java | 278 +++ .../cloud/dialogflow/v2/ContextsClient.java | 852 ++++++++ .../cloud/dialogflow/v2/ContextsSettings.java | 230 ++ .../dialogflow/v2/EntityTypesClient.java | 1937 +++++++++++++++++ .../dialogflow/v2/EntityTypesSettings.java | 345 +++ .../cloud/dialogflow/v2/IntentsClient.java | 1254 +++++++++++ .../cloud/dialogflow/v2/IntentsSettings.java | 270 +++ .../v2/SessionEntityTypesClient.java | 786 +++++++ .../v2/SessionEntityTypesSettings.java | 232 ++ .../cloud/dialogflow/v2/SessionsClient.java | 348 +++ .../cloud/dialogflow/v2/SessionsSettings.java | 188 ++ .../cloud/dialogflow/v2/package-info.java | 211 ++ .../cloud/dialogflow/v2/stub/AgentsStub.java | 100 + .../v2/stub/AgentsStubSettings.java | 626 ++++++ .../dialogflow/v2/stub/ContextsStub.java | 74 + .../v2/stub/ContextsStubSettings.java | 455 ++++ .../dialogflow/v2/stub/EntityTypesStub.java | 134 ++ .../v2/stub/EntityTypesStubSettings.java | 814 +++++++ .../v2/stub/GrpcAgentsCallableFactory.java | 114 + .../dialogflow/v2/stub/GrpcAgentsStub.java | 309 +++ .../v2/stub/GrpcContextsCallableFactory.java | 114 + .../dialogflow/v2/stub/GrpcContextsStub.java | 259 +++ .../stub/GrpcEntityTypesCallableFactory.java | 114 + .../v2/stub/GrpcEntityTypesStub.java | 447 ++++ .../v2/stub/GrpcIntentsCallableFactory.java | 114 + .../dialogflow/v2/stub/GrpcIntentsStub.java | 316 +++ ...GrpcSessionEntityTypesCallableFactory.java | 114 + .../v2/stub/GrpcSessionEntityTypesStub.java | 280 +++ .../v2/stub/GrpcSessionsCallableFactory.java | 114 + .../dialogflow/v2/stub/GrpcSessionsStub.java | 169 ++ .../cloud/dialogflow/v2/stub/IntentsStub.java | 100 + .../v2/stub/IntentsStubSettings.java | 581 +++++ .../v2/stub/SessionEntityTypesStub.java | 75 + .../stub/SessionEntityTypesStubSettings.java | 468 ++++ .../dialogflow/v2/stub/SessionsStub.java | 49 + .../v2/stub/SessionsStubSettings.java | 290 +++ .../dialogflow/v2beta1/AgentsClient.java | 2 +- .../dialogflow/v2beta1/AgentsSettings.java | 1 + .../dialogflow/v2beta1/ContextsClient.java | 2 +- .../dialogflow/v2beta1/ContextsSettings.java | 1 + .../dialogflow/v2beta1/EntityTypesClient.java | 2 +- .../v2beta1/EntityTypesSettings.java | 1 + .../dialogflow/v2beta1/IntentsClient.java | 2 +- .../dialogflow/v2beta1/IntentsSettings.java | 1 + .../v2beta1/SessionEntityTypesClient.java | 2 +- .../v2beta1/SessionEntityTypesSettings.java | 1 + .../dialogflow/v2beta1/SessionsClient.java | 2 +- .../dialogflow/v2beta1/SessionsSettings.java | 1 + .../dialogflow/v2beta1/stub/AgentsStub.java | 3 + .../v2beta1/stub/AgentsStubSettings.java | 1 + .../dialogflow/v2beta1/stub/ContextsStub.java | 3 + .../v2beta1/stub/ContextsStubSettings.java | 1 + .../v2beta1/stub/EntityTypesStub.java | 3 + .../v2beta1/stub/EntityTypesStubSettings.java | 1 + .../v2beta1/stub/GrpcAgentsStub.java | 2 +- .../v2beta1/stub/GrpcContextsStub.java | 2 +- .../v2beta1/stub/GrpcEntityTypesStub.java | 2 +- .../v2beta1/stub/GrpcIntentsStub.java | 2 +- .../stub/GrpcSessionEntityTypesStub.java | 2 +- .../v2beta1/stub/GrpcSessionsStub.java | 2 +- .../dialogflow/v2beta1/stub/IntentsStub.java | 3 + .../v2beta1/stub/IntentsStubSettings.java | 1 + .../v2beta1/stub/SessionEntityTypesStub.java | 3 + .../stub/SessionEntityTypesStubSettings.java | 1 + .../dialogflow/v2beta1/stub/SessionsStub.java | 3 + .../v2beta1/stub/SessionsStubSettings.java | 1 + .../cloud/dialogflow/v2/AgentsClientTest.java | 298 +++ .../dialogflow/v2/ContextsClientTest.java | 344 +++ .../dialogflow/v2/EntityTypesClientTest.java | 853 ++++++++ .../dialogflow/v2/IntentsClientTest.java | 656 ++++++ .../cloud/dialogflow/v2/MockAgents.java | 57 + .../cloud/dialogflow/v2/MockAgentsImpl.java | 145 ++ .../cloud/dialogflow/v2/MockContexts.java | 57 + .../cloud/dialogflow/v2/MockContextsImpl.java | 147 ++ .../cloud/dialogflow/v2/MockEntityTypes.java | 57 + .../dialogflow/v2/MockEntityTypesImpl.java | 210 ++ .../cloud/dialogflow/v2/MockIntents.java | 57 + .../cloud/dialogflow/v2/MockIntentsImpl.java | 161 ++ .../dialogflow/v2/MockSessionEntityTypes.java | 57 + .../v2/MockSessionEntityTypesImpl.java | 135 ++ .../cloud/dialogflow/v2/MockSessions.java | 57 + .../cloud/dialogflow/v2/MockSessionsImpl.java | 103 + .../v2/SessionEntityTypesClientTest.java | 315 +++ .../dialogflow/v2/SessionsClientTest.java | 202 ++ .../google/cloud/dlp/v2/DlpServiceClient.java | 50 +- .../cloud/dlp/v2/DlpServiceSettings.java | 1 + .../cloud/dlp/v2/stub/DlpServiceStub.java | 3 + .../dlp/v2/stub/DlpServiceStubSettings.java | 1 + .../cloud/dlp/v2/stub/GrpcDlpServiceStub.java | 2 +- .../cloud/dlp/v2beta1/DlpServiceClient.java | 2 +- .../cloud/dlp/v2beta1/DlpServiceSettings.java | 1 + .../dlp/v2beta1/stub/DlpServiceStub.java | 3 + .../v2beta1/stub/DlpServiceStubSettings.java | 1 + .../dlp/v2beta1/stub/GrpcDlpServiceStub.java | 2 +- .../v1beta1/ErrorGroupServiceClient.java | 2 +- .../v1beta1/ErrorGroupServiceSettings.java | 1 + .../v1beta1/ErrorStatsServiceClient.java | 2 +- .../v1beta1/ErrorStatsServiceSettings.java | 1 + .../v1beta1/ReportErrorsServiceClient.java | 2 +- .../v1beta1/ReportErrorsServiceSettings.java | 1 + .../v1beta1/stub/ErrorGroupServiceStub.java | 3 + .../stub/ErrorGroupServiceStubSettings.java | 1 + .../v1beta1/stub/ErrorStatsServiceStub.java | 3 + .../stub/ErrorStatsServiceStubSettings.java | 1 + .../stub/GrpcErrorGroupServiceStub.java | 2 +- .../stub/GrpcErrorStatsServiceStub.java | 2 +- .../stub/GrpcReportErrorsServiceStub.java | 2 +- .../v1beta1/stub/ReportErrorsServiceStub.java | 3 + .../stub/ReportErrorsServiceStubSettings.java | 1 + .../firestore/v1beta1/FirestoreClient.java | 2 +- .../firestore/v1beta1/FirestoreSettings.java | 1 + .../firestore/v1beta1/stub/FirestoreStub.java | 3 + .../v1beta1/stub/FirestoreStubSettings.java | 1 + .../v1beta1/stub/GrpcFirestoreStub.java | 2 +- .../language/v1/LanguageServiceClient.java | 2 +- .../language/v1/LanguageServiceSettings.java | 1 + .../v1/stub/GrpcLanguageServiceStub.java | 2 +- .../language/v1/stub/LanguageServiceStub.java | 3 + .../v1/stub/LanguageServiceStubSettings.java | 1 + .../v1beta2/LanguageServiceClient.java | 2 +- .../v1beta2/LanguageServiceSettings.java | 1 + .../v1beta2/stub/GrpcLanguageServiceStub.java | 2 +- .../v1beta2/stub/LanguageServiceStub.java | 3 + .../stub/LanguageServiceStubSettings.java | 1 + .../google/cloud/logging/v2/ConfigClient.java | 2 +- .../cloud/logging/v2/ConfigSettings.java | 1 + .../cloud/logging/v2/LoggingClient.java | 2 +- .../cloud/logging/v2/LoggingSettings.java | 1 + .../cloud/logging/v2/MetricsClient.java | 2 +- .../cloud/logging/v2/MetricsSettings.java | 1 + .../logging/v2/stub/ConfigServiceV2Stub.java | 3 + .../v2/stub/ConfigServiceV2StubSettings.java | 1 + .../v2/stub/GrpcConfigServiceV2Stub.java | 2 +- .../v2/stub/GrpcLoggingServiceV2Stub.java | 2 +- .../v2/stub/GrpcMetricsServiceV2Stub.java | 2 +- .../logging/v2/stub/LoggingServiceV2Stub.java | 3 + .../v2/stub/LoggingServiceV2StubSettings.java | 1 + .../logging/v2/stub/MetricsServiceV2Stub.java | 3 + .../v2/stub/MetricsServiceV2StubSettings.java | 1 + .../v3/AlertPolicyServiceClient.java | 2 +- .../v3/AlertPolicyServiceSettings.java | 1 + .../monitoring/v3/GroupServiceClient.java | 2 +- .../monitoring/v3/GroupServiceSettings.java | 1 + .../monitoring/v3/MetricServiceClient.java | 2 +- .../monitoring/v3/MetricServiceSettings.java | 1 + .../v3/NotificationChannelServiceClient.java | 2 +- .../NotificationChannelServiceSettings.java | 1 + .../v3/UptimeCheckServiceClient.java | 2 +- .../v3/UptimeCheckServiceSettings.java | 1 + .../v3/stub/AlertPolicyServiceStub.java | 3 + .../stub/AlertPolicyServiceStubSettings.java | 1 + .../monitoring/v3/stub/GroupServiceStub.java | 3 + .../v3/stub/GroupServiceStubSettings.java | 1 + .../v3/stub/GrpcAlertPolicyServiceStub.java | 2 +- .../v3/stub/GrpcGroupServiceStub.java | 2 +- .../v3/stub/GrpcMetricServiceStub.java | 2 +- .../GrpcNotificationChannelServiceStub.java | 2 +- .../v3/stub/GrpcUptimeCheckServiceStub.java | 2 +- .../monitoring/v3/stub/MetricServiceStub.java | 3 + .../v3/stub/MetricServiceStubSettings.java | 1 + .../stub/NotificationChannelServiceStub.java | 3 + ...otificationChannelServiceStubSettings.java | 1 + .../v3/stub/UptimeCheckServiceStub.java | 3 + .../stub/UptimeCheckServiceStubSettings.java | 1 + .../oslogin/v1/OsLoginServiceClient.java | 2 +- .../oslogin/v1/OsLoginServiceSettings.java | 1 + .../v1/stub/GrpcOsLoginServiceStub.java | 2 +- .../oslogin/v1/stub/OsLoginServiceStub.java | 3 + .../v1/stub/OsLoginServiceStubSettings.java | 1 + .../pubsub/v1/SubscriptionAdminClient.java | 2 +- .../pubsub/v1/SubscriptionAdminSettings.java | 1 + .../cloud/pubsub/v1/TopicAdminClient.java | 2 +- .../cloud/pubsub/v1/TopicAdminSettings.java | 1 + .../pubsub/v1/stub/GrpcPublisherStub.java | 2 +- .../pubsub/v1/stub/GrpcSubscriberStub.java | 2 +- .../cloud/pubsub/v1/stub/PublisherStub.java | 3 + .../pubsub/v1/stub/PublisherStubSettings.java | 1 + .../cloud/pubsub/v1/stub/SubscriberStub.java | 3 + .../v1/stub/SubscriberStubSettings.java | 1 + .../cloud/spanner/v1/SpannerClient.java | 2 +- .../cloud/spanner/v1/SpannerSettings.java | 1 + .../spanner/v1/stub/GrpcSpannerStub.java | 2 +- .../cloud/spanner/v1/stub/SpannerStub.java | 3 + .../spanner/v1/stub/SpannerStubSettings.java | 1 + .../google/cloud/speech/v1/SpeechClient.java | 2 +- .../cloud/speech/v1/SpeechSettings.java | 1 + .../cloud/speech/v1/stub/GrpcSpeechStub.java | 2 +- .../cloud/speech/v1/stub/SpeechStub.java | 3 + .../speech/v1/stub/SpeechStubSettings.java | 1 + .../cloud/speech/v1beta1/SpeechClient.java | 2 +- .../cloud/speech/v1beta1/SpeechSettings.java | 1 + .../speech/v1beta1/stub/GrpcSpeechStub.java | 2 +- .../cloud/speech/v1beta1/stub/SpeechStub.java | 3 + .../v1beta1/stub/SpeechStubSettings.java | 1 + .../cloud/speech/v1p1beta1/SpeechClient.java | 2 +- .../speech/v1p1beta1/SpeechSettings.java | 1 + .../speech/v1p1beta1/stub/GrpcSpeechStub.java | 2 +- .../speech/v1p1beta1/stub/SpeechStub.java | 3 + .../v1p1beta1/stub/SpeechStubSettings.java | 1 + .../v1beta1/TextToSpeechClient.java | 2 +- .../v1beta1/TextToSpeechSettings.java | 1 + .../v1beta1/stub/GrpcTextToSpeechStub.java | 2 +- .../v1beta1/stub/TextToSpeechStub.java | 3 + .../stub/TextToSpeechStubSettings.java | 1 + .../cloud/trace/v1/TraceServiceClient.java | 2 +- .../cloud/trace/v1/TraceServiceSettings.java | 1 + .../trace/v1/stub/GrpcTraceServiceStub.java | 2 +- .../cloud/trace/v1/stub/TraceServiceStub.java | 3 + .../v1/stub/TraceServiceStubSettings.java | 1 + .../cloud/trace/v2/TraceServiceClient.java | 2 +- .../cloud/trace/v2/TraceServiceSettings.java | 1 + .../trace/v2/stub/GrpcTraceServiceStub.java | 2 +- .../cloud/trace/v2/stub/TraceServiceStub.java | 3 + .../v2/stub/TraceServiceStubSettings.java | 1 + .../VideoIntelligenceServiceClient.java | 2 +- .../VideoIntelligenceServiceSettings.java | 1 + .../GrpcVideoIntelligenceServiceStub.java | 2 +- .../stub/VideoIntelligenceServiceStub.java | 3 + .../VideoIntelligenceServiceStubSettings.java | 1 + .../cloud/vision/v1/ImageAnnotatorClient.java | 2 +- .../vision/v1/ImageAnnotatorSettings.java | 1 + .../v1/stub/GrpcImageAnnotatorStub.java | 2 +- .../vision/v1/stub/ImageAnnotatorStub.java | 3 + .../v1/stub/ImageAnnotatorStubSettings.java | 1 + .../v1p1beta1/ImageAnnotatorClient.java | 2 +- .../v1p1beta1/ImageAnnotatorSettings.java | 1 + .../stub/GrpcImageAnnotatorStub.java | 2 +- .../v1p1beta1/stub/ImageAnnotatorStub.java | 3 + .../stub/ImageAnnotatorStubSettings.java | 1 + .../v1p2beta1/ImageAnnotatorClient.java | 2 +- .../v1p2beta1/ImageAnnotatorSettings.java | 1 + .../stub/GrpcImageAnnotatorStub.java | 2 +- .../v1p2beta1/stub/ImageAnnotatorStub.java | 3 + .../stub/ImageAnnotatorStubSettings.java | 1 + pom.xml | 2 +- 263 files changed, 18388 insertions(+), 111 deletions(-) create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/package-info.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsCallableFactory.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsCallableFactory.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesCallableFactory.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsCallableFactory.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesCallableFactory.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsCallableFactory.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStub.java create mode 100644 google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientTest.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientTest.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientTest.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientTest.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgents.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgentsImpl.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContexts.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContextsImpl.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypes.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypesImpl.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntents.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntentsImpl.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypes.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypesImpl.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessions.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionsImpl.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientTest.java create mode 100644 google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientTest.java diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceClient.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceClient.java index f6a1a0b228c3..b0aa8c19fbcf 100644 --- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceClient.java +++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceClient.java @@ -1590,7 +1590,7 @@ private final CheckValidCredsResponse checkValidCreds(CheckValidCredsRequest req } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java index 84d13ea60c10..b8d5c5fd4a7b 100644 --- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java +++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/DataTransferServiceSettings.java @@ -228,6 +228,7 @@ public DataTransferServiceStubSettings.Builder getStubSettingsBuilder() { return ((DataTransferServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStub.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStub.java index 0a5c60bf5c34..271af9afc41c 100644 --- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStub.java +++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStub.java @@ -133,4 +133,7 @@ public UnaryCallable deleteTransferRunCallable( public UnaryCallable checkValidCredsCallable() { throw new UnsupportedOperationException("Not implemented: checkValidCredsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java index 1221d16238ca..ddbda60a4462 100644 --- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java +++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/DataTransferServiceStubSettings.java @@ -759,6 +759,7 @@ protected Builder(DataTransferServiceStubSettings settings) { checkValidCredsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java index cd72c1dc8f24..ab8d8ef3c190 100644 --- a/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java +++ b/google-cloud-bigquerydatatransfer/src/main/java/com/google/cloud/bigquery/datatransfer/v1/stub/GrpcDataTransferServiceStub.java @@ -485,7 +485,7 @@ public UnaryCallable checkValid } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java index 1711b429d689..699189bde37e 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataClient.java @@ -712,7 +712,7 @@ public final ReadModifyWriteRowResponse readModifyWriteRow(ReadModifyWriteRowReq } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java index 316450c906e3..7d586e90ab7d 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BaseBigtableDataSettings.java @@ -189,6 +189,7 @@ public BigtableStubSettings.Builder getStubSettingsBuilder() { return ((BigtableStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java index 36c25f0936ee..c8cf734a2825 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java @@ -69,4 +69,7 @@ public ServerStreamingCallable mutateRows readModifyWriteRowCallable() { throw new UnsupportedOperationException("Not implemented: readModifyWriteRowCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java index 2671f40913bb..66748631ed30 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java @@ -331,6 +331,7 @@ protected Builder(BigtableStubSettings settings) { mutateRowSettings, checkAndMutateRowSettings, readModifyWriteRowSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java index 62ebc399222c..798d9a09e590 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java @@ -292,7 +292,7 @@ public ServerStreamingCallable mutateRows } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-bom/pom.xml b/google-cloud-bom/pom.xml index 497cdb600ac2..348a5d5859e7 100644 --- a/google-cloud-bom/pom.xml +++ b/google-cloud-bom/pom.xml @@ -173,8 +173,8 @@ 1.23.0 1.23.0 0.40.0 - 0.8.0 - 1.7.0 + 0.9.0 + 1.8.0 @@ -429,6 +429,16 @@ grpc-google-cloud-dialogflow-v2beta1 ${generated-proto-beta.version} + + com.google.api.grpc + proto-google-cloud-dialogflow-v2 + ${generated-proto-beta.version} + + + com.google.api.grpc + grpc-google-cloud-dialogflow-v2 + ${generated-proto-beta.version} + com.google.cloud google-cloud-dns diff --git a/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerClient.java b/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerClient.java index 5edfbb8f8856..debffce50723 100644 --- a/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerClient.java +++ b/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerClient.java @@ -2772,7 +2772,7 @@ public final Operation setMaintenancePolicy(SetMaintenancePolicyRequest request) } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerSettings.java b/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerSettings.java index b11a472615b4..4a61b4072080 100644 --- a/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerSettings.java +++ b/google-cloud-container/src/main/java/com/google/cloud/container/v1/ClusterManagerSettings.java @@ -334,6 +334,7 @@ public ClusterManagerStubSettings.Builder getStubSettingsBuilder() { return ((ClusterManagerStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStub.java b/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStub.java index ec22e6c1bfbc..5fce960ddada 100644 --- a/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStub.java +++ b/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStub.java @@ -188,4 +188,7 @@ public UnaryCallable setNetworkPolicyCallabl public UnaryCallable setMaintenancePolicyCallable() { throw new UnsupportedOperationException("Not implemented: setMaintenancePolicyCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStubSettings.java b/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStubSettings.java index 684d8d58e842..8a46de0ccdca 100644 --- a/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStubSettings.java +++ b/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/ClusterManagerStubSettings.java @@ -823,6 +823,7 @@ protected Builder(ClusterManagerStubSettings settings) { setMaintenancePolicySettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/GrpcClusterManagerStub.java b/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/GrpcClusterManagerStub.java index dd1f19df11b7..66a166c7b1a2 100644 --- a/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/GrpcClusterManagerStub.java +++ b/google-cloud-container/src/main/java/com/google/cloud/container/v1/stub/GrpcClusterManagerStub.java @@ -772,7 +772,7 @@ public UnaryCallable setMaintenancePolic } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerClient.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerClient.java index 3e25efba86be..abb00c422127 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerClient.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerClient.java @@ -811,7 +811,7 @@ public final UnaryCallable diagnoseClusterCal } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerSettings.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerSettings.java index a530d9240fef..d9267bb5a021 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerSettings.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerSettings.java @@ -204,6 +204,7 @@ public ClusterControllerStubSettings.Builder getStubSettingsBuilder() { return ((ClusterControllerStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerClient.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerClient.java index 76ae90cbde9d..4771390dd36e 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerClient.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerClient.java @@ -670,7 +670,7 @@ public final UnaryCallable deleteJobCallable() { } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerSettings.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerSettings.java index cbe821d59af4..bfe3c3d8c480 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerSettings.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/JobControllerSettings.java @@ -178,6 +178,7 @@ public JobControllerStubSettings.Builder getStubSettingsBuilder() { return ((JobControllerStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStub.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStub.java index ec05ae40c769..0223661ba7a2 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStub.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStub.java @@ -97,4 +97,7 @@ public UnaryCallable listClustersCall public UnaryCallable diagnoseClusterCallable() { throw new UnsupportedOperationException("Not implemented: diagnoseClusterCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStubSettings.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStubSettings.java index 03a8c5cdcee5..bb0002dc68b8 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStubSettings.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/ClusterControllerStubSettings.java @@ -559,6 +559,7 @@ protected Builder(ClusterControllerStubSettings settings) { diagnoseClusterSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcClusterControllerStub.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcClusterControllerStub.java index 235499c5b2ca..b0e36a81753f 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcClusterControllerStub.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcClusterControllerStub.java @@ -296,7 +296,7 @@ public UnaryCallable diagnoseClusterCallable( } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcJobControllerStub.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcJobControllerStub.java index 40426a10ef19..c17d2e584856 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcJobControllerStub.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcJobControllerStub.java @@ -221,7 +221,7 @@ public UnaryCallable deleteJobCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStub.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStub.java index 5a45981f8407..591488ef760e 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStub.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStub.java @@ -68,4 +68,7 @@ public UnaryCallable cancelJobCallable() { public UnaryCallable deleteJobCallable() { throw new UnsupportedOperationException("Not implemented: deleteJobCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStubSettings.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStubSettings.java index 7addb1fc98c8..c1c85631a038 100644 --- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStubSettings.java +++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/JobControllerStubSettings.java @@ -397,6 +397,7 @@ protected Builder(JobControllerStubSettings settings) { deleteJobSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/pom.xml b/google-cloud-dialogflow/pom.xml index e620079665ab..b6a86d3ef0c8 100644 --- a/google-cloud-dialogflow/pom.xml +++ b/google-cloud-dialogflow/pom.xml @@ -7,7 +7,7 @@ Google Cloud Dialog Flow API https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-dialogflow - Java idiomatic client for Cloud Dialog Flow API v2beta1. + Java idiomatic client for Cloud Dialog Flow API. com.google.cloud @@ -15,7 +15,7 @@ 0.43.1-alpha-SNAPSHOT - google-cloud-dialogflow-v2beta1 + google-cloud-dialogflow @@ -30,6 +30,10 @@ com.google.api.grpc proto-google-cloud-dialogflow-v2beta1 + + com.google.api.grpc + proto-google-cloud-dialogflow-v2 + io.grpc grpc-netty-shaded @@ -68,6 +72,11 @@ grpc-google-cloud-dialogflow-v2beta1 test + + com.google.api.grpc + grpc-google-cloud-dialogflow-v2 + test + com.google.api gax-grpc diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java new file mode 100644 index 000000000000..430521b7ad21 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java @@ -0,0 +1,981 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.stub.AgentsStub; +import com.google.cloud.dialogflow.v2.stub.AgentsStubSettings; +import com.google.longrunning.Operation; +import com.google.longrunning.OperationsClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: Agents are best described as Natural Language Understanding (NLU) modules + * that transform user requests into actionable data. You can include agents in your app, product, + * or service to determine user intent and respond to the user in a natural way. + * + *

After you create an agent, you can add [Intents][google.cloud.dialogflow.v2.Intents], + * [Contexts][google.cloud.dialogflow.v2.Contexts], [Entity + * Types][google.cloud.dialogflow.v2.EntityTypes], + * [Webhooks][google.cloud.dialogflow.v2.WebhookRequest], and so on to manage the flow of a + * conversation and match user input to predefined intents and actions. + * + *

You can create an agent using both Dialogflow Standard Edition and Dialogflow Enterprise + * Edition. For details, see [Dialogflow Editions](/dialogflow-enterprise/docs/editions). + * + *

You can save your agent for backup or versioning by exporting the agent by using the + * [ExportAgent][google.cloud.dialogflow.v2.Agents.ExportAgent] method. You can import a saved agent + * by using the [ImportAgent][google.cloud.dialogflow.v2.Agents.ImportAgent] method. + * + *

Dialogflow provides several [prebuilt agents](https://dialogflow.com/docs/prebuilt-agents) for + * common conversation scenarios such as determining a date and time, converting currency, and so + * on. + * + *

For more information about agents, see the [Dialogflow + * documentation](https://dialogflow.com/docs/agents). + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (AgentsClient agentsClient = AgentsClient.create()) {
+ *   ProjectName parent = ProjectName.of("[PROJECT]");
+ *   Agent response = agentsClient.getAgent(parent);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the agentsClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of AgentsSettings to create(). + * For example: + * + *

To customize credentials: + * + *

+ * 
+ * AgentsSettings agentsSettings =
+ *     AgentsSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * AgentsClient agentsClient =
+ *     AgentsClient.create(agentsSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * AgentsSettings agentsSettings =
+ *     AgentsSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * AgentsClient agentsClient =
+ *     AgentsClient.create(agentsSettings);
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class AgentsClient implements BackgroundResource { + private final AgentsSettings settings; + private final AgentsStub stub; + private final OperationsClient operationsClient; + + /** Constructs an instance of AgentsClient with default settings. */ + public static final AgentsClient create() throws IOException { + return create(AgentsSettings.newBuilder().build()); + } + + /** + * Constructs an instance of AgentsClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final AgentsClient create(AgentsSettings settings) throws IOException { + return new AgentsClient(settings); + } + + /** + * Constructs an instance of AgentsClient, using the given stub for making calls. This is for + * advanced usage - prefer to use AgentsSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final AgentsClient create(AgentsStub stub) { + return new AgentsClient(stub); + } + + /** + * Constructs an instance of AgentsClient, using the given settings. This is protected so that it + * is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected AgentsClient(AgentsSettings settings) throws IOException { + this.settings = settings; + this.stub = ((AgentsStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected AgentsClient(AgentsStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + public final AgentsSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public AgentsStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getOperationsClient() { + return operationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified agent. + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Agent response = agentsClient.getAgent(parent);
+   * }
+   * 
+ * + * @param parent Required. The project that the agent to fetch is associated with. Format: + * `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Agent getAgent(ProjectName parent) { + + GetAgentRequest request = + GetAgentRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return getAgent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified agent. + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Agent response = agentsClient.getAgent(parent.toString());
+   * }
+   * 
+ * + * @param parent Required. The project that the agent to fetch is associated with. Format: + * `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Agent getAgent(String parent) { + + GetAgentRequest request = GetAgentRequest.newBuilder().setParent(parent).build(); + return getAgent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified agent. + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   GetAgentRequest request = GetAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   Agent response = agentsClient.getAgent(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final Agent getAgent(GetAgentRequest request) { + return getAgentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified agent. + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   GetAgentRequest request = GetAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<Agent> future = agentsClient.getAgentCallable().futureCall(request);
+   *   // Do something
+   *   Agent response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getAgentCallable() { + return stub.getAgentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of agents. + * + *

Since there is at most one conversational agent per project, this method is useful primarily + * for listing all agents across projects the caller has access to. One can achieve that with a + * wildcard project collection id "-". Refer to [List + * Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections). + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (Agent element : agentsClient.searchAgents(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The project to list agents from. Format: `projects/<Project ID or + * '-'>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SearchAgentsPagedResponse searchAgents(ProjectName parent) { + SearchAgentsRequest request = + SearchAgentsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return searchAgents(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of agents. + * + *

Since there is at most one conversational agent per project, this method is useful primarily + * for listing all agents across projects the caller has access to. One can achieve that with a + * wildcard project collection id "-". Refer to [List + * Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections). + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (Agent element : agentsClient.searchAgents(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The project to list agents from. Format: `projects/<Project ID or + * '-'>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SearchAgentsPagedResponse searchAgents(String parent) { + SearchAgentsRequest request = SearchAgentsRequest.newBuilder().setParent(parent).build(); + return searchAgents(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of agents. + * + *

Since there is at most one conversational agent per project, this method is useful primarily + * for listing all agents across projects the caller has access to. One can achieve that with a + * wildcard project collection id "-". Refer to [List + * Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections). + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   SearchAgentsRequest request = SearchAgentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (Agent element : agentsClient.searchAgents(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SearchAgentsPagedResponse searchAgents(SearchAgentsRequest request) { + return searchAgentsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of agents. + * + *

Since there is at most one conversational agent per project, this method is useful primarily + * for listing all agents across projects the caller has access to. One can achieve that with a + * wildcard project collection id "-". Refer to [List + * Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections). + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   SearchAgentsRequest request = SearchAgentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<SearchAgentsPagedResponse> future = agentsClient.searchAgentsPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (Agent element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + searchAgentsPagedCallable() { + return stub.searchAgentsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of agents. + * + *

Since there is at most one conversational agent per project, this method is useful primarily + * for listing all agents across projects the caller has access to. One can achieve that with a + * wildcard project collection id "-". Refer to [List + * Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections). + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   SearchAgentsRequest request = SearchAgentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     SearchAgentsResponse response = agentsClient.searchAgentsCallable().call(request);
+   *     for (Agent element : response.getAgentsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable searchAgentsCallable() { + return stub.searchAgentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Trains the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Empty response = agentsClient.trainAgentAsync(parent).get();
+   * }
+   * 
+ * + * @param parent Required. The project that the agent to train is associated with. Format: + * `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture trainAgentAsync(ProjectName parent) { + + TrainAgentRequest request = + TrainAgentRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return trainAgentAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Trains the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Empty response = agentsClient.trainAgentAsync(parent.toString()).get();
+   * }
+   * 
+ * + * @param parent Required. The project that the agent to train is associated with. Format: + * `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture trainAgentAsync(String parent) { + + TrainAgentRequest request = TrainAgentRequest.newBuilder().setParent(parent).build(); + return trainAgentAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Trains the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   TrainAgentRequest request = TrainAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   Empty response = agentsClient.trainAgentAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final OperationFuture trainAgentAsync(TrainAgentRequest request) { + return trainAgentOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Trains the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   TrainAgentRequest request = TrainAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   OperationFuture<Operation> future = agentsClient.trainAgentOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable trainAgentOperationCallable() { + return stub.trainAgentOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Trains the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   TrainAgentRequest request = TrainAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = agentsClient.trainAgentCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable trainAgentCallable() { + return stub.trainAgentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Exports the specified agent to a ZIP file. + * + *

Operation <response: + * [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ExportAgentResponse response = agentsClient.exportAgentAsync(parent).get();
+   * }
+   * 
+ * + * @param parent Required. The project that the agent to export is associated with. Format: + * `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture exportAgentAsync(ProjectName parent) { + + ExportAgentRequest request = + ExportAgentRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return exportAgentAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Exports the specified agent to a ZIP file. + * + *

Operation <response: + * [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ExportAgentResponse response = agentsClient.exportAgentAsync(parent.toString()).get();
+   * }
+   * 
+ * + * @param parent Required. The project that the agent to export is associated with. Format: + * `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture exportAgentAsync(String parent) { + + ExportAgentRequest request = ExportAgentRequest.newBuilder().setParent(parent).build(); + return exportAgentAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Exports the specified agent to a ZIP file. + * + *

Operation <response: + * [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ExportAgentRequest request = ExportAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ExportAgentResponse response = agentsClient.exportAgentAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture exportAgentAsync( + ExportAgentRequest request) { + return exportAgentOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Exports the specified agent to a ZIP file. + * + *

Operation <response: + * [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ExportAgentRequest request = ExportAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   OperationFuture<Operation> future = agentsClient.exportAgentOperationCallable().futureCall(request);
+   *   // Do something
+   *   ExportAgentResponse response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + exportAgentOperationCallable() { + return stub.exportAgentOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Exports the specified agent to a ZIP file. + * + *

Operation <response: + * [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ExportAgentRequest request = ExportAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = agentsClient.exportAgentCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable exportAgentCallable() { + return stub.exportAgentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Imports the specified agent from a ZIP file. + * + *

Uploads new intents and entity types without deleting the existing ones. Intents and entity + * types with the same name are replaced with the new versions from ImportAgentRequest. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ImportAgentRequest request = ImportAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   Empty response = agentsClient.importAgentAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture importAgentAsync(ImportAgentRequest request) { + return importAgentOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Imports the specified agent from a ZIP file. + * + *

Uploads new intents and entity types without deleting the existing ones. Intents and entity + * types with the same name are replaced with the new versions from ImportAgentRequest. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ImportAgentRequest request = ImportAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   OperationFuture<Operation> future = agentsClient.importAgentOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable importAgentOperationCallable() { + return stub.importAgentOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Imports the specified agent from a ZIP file. + * + *

Uploads new intents and entity types without deleting the existing ones. Intents and entity + * types with the same name are replaced with the new versions from ImportAgentRequest. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ImportAgentRequest request = ImportAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = agentsClient.importAgentCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable importAgentCallable() { + return stub.importAgentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Restores the specified agent from a ZIP file. + * + *

Replaces the current agent version with a new one. All the intents and entity types in the + * older version are deleted. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   Empty response = agentsClient.restoreAgentAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture restoreAgentAsync(RestoreAgentRequest request) { + return restoreAgentOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Restores the specified agent from a ZIP file. + * + *

Replaces the current agent version with a new one. All the intents and entity types in the + * older version are deleted. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   OperationFuture<Operation> future = agentsClient.restoreAgentOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + restoreAgentOperationCallable() { + return stub.restoreAgentOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Restores the specified agent from a ZIP file. + * + *

Replaces the current agent version with a new one. All the intents and entity types in the + * older version are deleted. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (AgentsClient agentsClient = AgentsClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   RestoreAgentRequest request = RestoreAgentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = agentsClient.restoreAgentCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable restoreAgentCallable() { + return stub.restoreAgentCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class SearchAgentsPagedResponse + extends AbstractPagedListResponse< + SearchAgentsRequest, SearchAgentsResponse, Agent, SearchAgentsPage, + SearchAgentsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + SearchAgentsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public SearchAgentsPagedResponse apply(SearchAgentsPage input) { + return new SearchAgentsPagedResponse(input); + } + }); + } + + private SearchAgentsPagedResponse(SearchAgentsPage page) { + super(page, SearchAgentsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class SearchAgentsPage + extends AbstractPage { + + private SearchAgentsPage( + PageContext context, + SearchAgentsResponse response) { + super(context, response); + } + + private static SearchAgentsPage createEmptyPage() { + return new SearchAgentsPage(null, null); + } + + @Override + protected SearchAgentsPage createPage( + PageContext context, + SearchAgentsResponse response) { + return new SearchAgentsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class SearchAgentsFixedSizeCollection + extends AbstractFixedSizeCollection< + SearchAgentsRequest, SearchAgentsResponse, Agent, SearchAgentsPage, + SearchAgentsFixedSizeCollection> { + + private SearchAgentsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static SearchAgentsFixedSizeCollection createEmptyCollection() { + return new SearchAgentsFixedSizeCollection(null, 0); + } + + @Override + protected SearchAgentsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new SearchAgentsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java new file mode 100644 index 000000000000..05e3501e58b0 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsSettings.java @@ -0,0 +1,278 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.dialogflow.v2.stub.AgentsStubSettings; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link AgentsClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getAgent to 30 seconds: + * + *

+ * 
+ * AgentsSettings.Builder agentsSettingsBuilder =
+ *     AgentsSettings.newBuilder();
+ * agentsSettingsBuilder.getAgentSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * AgentsSettings agentsSettings = agentsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class AgentsSettings extends ClientSettings { + /** Returns the object with the settings used for calls to getAgent. */ + public UnaryCallSettings getAgentSettings() { + return ((AgentsStubSettings) getStubSettings()).getAgentSettings(); + } + + /** Returns the object with the settings used for calls to searchAgents. */ + public PagedCallSettings + searchAgentsSettings() { + return ((AgentsStubSettings) getStubSettings()).searchAgentsSettings(); + } + + /** Returns the object with the settings used for calls to trainAgent. */ + public UnaryCallSettings trainAgentSettings() { + return ((AgentsStubSettings) getStubSettings()).trainAgentSettings(); + } + + /** Returns the object with the settings used for calls to trainAgent. */ + public OperationCallSettings trainAgentOperationSettings() { + return ((AgentsStubSettings) getStubSettings()).trainAgentOperationSettings(); + } + + /** Returns the object with the settings used for calls to exportAgent. */ + public UnaryCallSettings exportAgentSettings() { + return ((AgentsStubSettings) getStubSettings()).exportAgentSettings(); + } + + /** Returns the object with the settings used for calls to exportAgent. */ + public OperationCallSettings + exportAgentOperationSettings() { + return ((AgentsStubSettings) getStubSettings()).exportAgentOperationSettings(); + } + + /** Returns the object with the settings used for calls to importAgent. */ + public UnaryCallSettings importAgentSettings() { + return ((AgentsStubSettings) getStubSettings()).importAgentSettings(); + } + + /** Returns the object with the settings used for calls to importAgent. */ + public OperationCallSettings importAgentOperationSettings() { + return ((AgentsStubSettings) getStubSettings()).importAgentOperationSettings(); + } + + /** Returns the object with the settings used for calls to restoreAgent. */ + public UnaryCallSettings restoreAgentSettings() { + return ((AgentsStubSettings) getStubSettings()).restoreAgentSettings(); + } + + /** Returns the object with the settings used for calls to restoreAgent. */ + public OperationCallSettings restoreAgentOperationSettings() { + return ((AgentsStubSettings) getStubSettings()).restoreAgentOperationSettings(); + } + + public static final AgentsSettings create(AgentsStubSettings stub) throws IOException { + return new AgentsSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return AgentsStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return AgentsStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return AgentsStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return AgentsStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return AgentsStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return AgentsStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AgentsStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected AgentsSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for AgentsSettings. */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(AgentsStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(AgentsStubSettings.newBuilder()); + } + + protected Builder(AgentsSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(AgentsStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public AgentsStubSettings.Builder getStubSettingsBuilder() { + return ((AgentsStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to getAgent. */ + public UnaryCallSettings.Builder getAgentSettings() { + return getStubSettingsBuilder().getAgentSettings(); + } + + /** Returns the builder for the settings used for calls to searchAgents. */ + public PagedCallSettings.Builder< + SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse> + searchAgentsSettings() { + return getStubSettingsBuilder().searchAgentsSettings(); + } + + /** Returns the builder for the settings used for calls to trainAgent. */ + public UnaryCallSettings.Builder trainAgentSettings() { + return getStubSettingsBuilder().trainAgentSettings(); + } + + /** Returns the builder for the settings used for calls to trainAgent. */ + public OperationCallSettings.Builder + trainAgentOperationSettings() { + return getStubSettingsBuilder().trainAgentOperationSettings(); + } + + /** Returns the builder for the settings used for calls to exportAgent. */ + public UnaryCallSettings.Builder exportAgentSettings() { + return getStubSettingsBuilder().exportAgentSettings(); + } + + /** Returns the builder for the settings used for calls to exportAgent. */ + public OperationCallSettings.Builder + exportAgentOperationSettings() { + return getStubSettingsBuilder().exportAgentOperationSettings(); + } + + /** Returns the builder for the settings used for calls to importAgent. */ + public UnaryCallSettings.Builder importAgentSettings() { + return getStubSettingsBuilder().importAgentSettings(); + } + + /** Returns the builder for the settings used for calls to importAgent. */ + public OperationCallSettings.Builder + importAgentOperationSettings() { + return getStubSettingsBuilder().importAgentOperationSettings(); + } + + /** Returns the builder for the settings used for calls to restoreAgent. */ + public UnaryCallSettings.Builder restoreAgentSettings() { + return getStubSettingsBuilder().restoreAgentSettings(); + } + + /** Returns the builder for the settings used for calls to restoreAgent. */ + public OperationCallSettings.Builder + restoreAgentOperationSettings() { + return getStubSettingsBuilder().restoreAgentOperationSettings(); + } + + @Override + public AgentsSettings build() throws IOException { + return new AgentsSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java new file mode 100644 index 000000000000..b6e141f1fe8c --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsClient.java @@ -0,0 +1,852 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.stub.ContextsStub; +import com.google.cloud.dialogflow.v2.stub.ContextsStubSettings; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: A context represents additional information included with user input or with + * an intent returned by the Dialogflow API. Contexts are helpful for differentiating user input + * which may be vague or have a different meaning depending on additional details from your + * application such as user setting and preferences, previous user input, where the user is in your + * application, geographic location, and so on. + * + *

You can include contexts as input parameters of a + * [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or + * [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) request, or + * as output contexts included in the returned intent. Contexts expire when an intent is matched, + * after the number of `DetectIntent` requests specified by the `lifespan_count` parameter, or after + * 10 minutes if no intents are matched for a `DetectIntent` request. + * + *

For more information about contexts, see the [Dialogflow + * documentation](https://dialogflow.com/docs/contexts). + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (ContextsClient contextsClient = ContextsClient.create()) {
+ *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+ *   Context response = contextsClient.getContext(name);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the contextsClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of ContextsSettings to create(). + * For example: + * + *

To customize credentials: + * + *

+ * 
+ * ContextsSettings contextsSettings =
+ *     ContextsSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * ContextsClient contextsClient =
+ *     ContextsClient.create(contextsSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * ContextsSettings contextsSettings =
+ *     ContextsSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * ContextsClient contextsClient =
+ *     ContextsClient.create(contextsSettings);
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class ContextsClient implements BackgroundResource { + private final ContextsSettings settings; + private final ContextsStub stub; + + /** Constructs an instance of ContextsClient with default settings. */ + public static final ContextsClient create() throws IOException { + return create(ContextsSettings.newBuilder().build()); + } + + /** + * Constructs an instance of ContextsClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final ContextsClient create(ContextsSettings settings) throws IOException { + return new ContextsClient(settings); + } + + /** + * Constructs an instance of ContextsClient, using the given stub for making calls. This is for + * advanced usage - prefer to use ContextsSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final ContextsClient create(ContextsStub stub) { + return new ContextsClient(stub); + } + + /** + * Constructs an instance of ContextsClient, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected ContextsClient(ContextsSettings settings) throws IOException { + this.settings = settings; + this.stub = ((ContextsStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected ContextsClient(ContextsStub stub) { + this.settings = null; + this.stub = stub; + } + + public final ContextsSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public ContextsStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   for (Context element : contextsClient.listContexts(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The session to list all contexts from. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListContextsPagedResponse listContexts(SessionName parent) { + ListContextsRequest request = + ListContextsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listContexts(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   for (Context element : contextsClient.listContexts(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The session to list all contexts from. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListContextsPagedResponse listContexts(String parent) { + ListContextsRequest request = ListContextsRequest.newBuilder().setParent(parent).build(); + return listContexts(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   ListContextsRequest request = ListContextsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (Context element : contextsClient.listContexts(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListContextsPagedResponse listContexts(ListContextsRequest request) { + return listContextsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   ListContextsRequest request = ListContextsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListContextsPagedResponse> future = contextsClient.listContextsPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (Context element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listContextsPagedCallable() { + return stub.listContextsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   ListContextsRequest request = ListContextsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListContextsResponse response = contextsClient.listContextsCallable().call(request);
+   *     for (Context element : response.getContextsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listContextsCallable() { + return stub.listContextsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   Context response = contextsClient.getContext(name);
+   * }
+   * 
+ * + * @param name Required. The name of the context. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/contexts/<Context ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Context getContext(ContextName name) { + + GetContextRequest request = + GetContextRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getContext(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   Context response = contextsClient.getContext(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the context. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/contexts/<Context ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Context getContext(String name) { + + GetContextRequest request = GetContextRequest.newBuilder().setName(name).build(); + return getContext(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   GetContextRequest request = GetContextRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   Context response = contextsClient.getContext(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final Context getContext(GetContextRequest request) { + return getContextCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   GetContextRequest request = GetContextRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Context> future = contextsClient.getContextCallable().futureCall(request);
+   *   // Do something
+   *   Context response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getContextCallable() { + return stub.getContextCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   Context context = Context.newBuilder().build();
+   *   Context response = contextsClient.createContext(parent, context);
+   * }
+   * 
+ * + * @param parent Required. The session to create a context for. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>`. + * @param context Required. The context to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Context createContext(SessionName parent, Context context) { + + CreateContextRequest request = + CreateContextRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setContext(context) + .build(); + return createContext(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   Context context = Context.newBuilder().build();
+   *   Context response = contextsClient.createContext(parent.toString(), context);
+   * }
+   * 
+ * + * @param parent Required. The session to create a context for. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>`. + * @param context Required. The context to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Context createContext(String parent, Context context) { + + CreateContextRequest request = + CreateContextRequest.newBuilder().setParent(parent).setContext(context).build(); + return createContext(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   Context context = Context.newBuilder().build();
+   *   CreateContextRequest request = CreateContextRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setContext(context)
+   *     .build();
+   *   Context response = contextsClient.createContext(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Context createContext(CreateContextRequest request) { + return createContextCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   Context context = Context.newBuilder().build();
+   *   CreateContextRequest request = CreateContextRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setContext(context)
+   *     .build();
+   *   ApiFuture<Context> future = contextsClient.createContextCallable().futureCall(request);
+   *   // Do something
+   *   Context response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createContextCallable() { + return stub.createContextCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   Context context = Context.newBuilder().build();
+   *   Context response = contextsClient.updateContext(context);
+   * }
+   * 
+ * + * @param context Required. The context to update. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Context updateContext(Context context) { + + UpdateContextRequest request = UpdateContextRequest.newBuilder().setContext(context).build(); + return updateContext(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   Context context = Context.newBuilder().build();
+   *   UpdateContextRequest request = UpdateContextRequest.newBuilder()
+   *     .setContext(context)
+   *     .build();
+   *   Context response = contextsClient.updateContext(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Context updateContext(UpdateContextRequest request) { + return updateContextCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   Context context = Context.newBuilder().build();
+   *   UpdateContextRequest request = UpdateContextRequest.newBuilder()
+   *     .setContext(context)
+   *     .build();
+   *   ApiFuture<Context> future = contextsClient.updateContextCallable().futureCall(request);
+   *   // Do something
+   *   Context response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable updateContextCallable() { + return stub.updateContextCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   contextsClient.deleteContext(name);
+   * }
+   * 
+ * + * @param name Required. The name of the context to delete. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/contexts/<Context ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteContext(ContextName name) { + + DeleteContextRequest request = + DeleteContextRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteContext(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   contextsClient.deleteContext(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the context to delete. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/contexts/<Context ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteContext(String name) { + + DeleteContextRequest request = DeleteContextRequest.newBuilder().setName(name).build(); + deleteContext(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   DeleteContextRequest request = DeleteContextRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   contextsClient.deleteContext(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final void deleteContext(DeleteContextRequest request) { + deleteContextCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified context. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+   *   DeleteContextRequest request = DeleteContextRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = contextsClient.deleteContextCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteContextCallable() { + return stub.deleteContextCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes all active contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   contextsClient.deleteAllContexts(parent);
+   * }
+   * 
+ * + * @param parent Required. The name of the session to delete all contexts from. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteAllContexts(SessionName parent) { + + DeleteAllContextsRequest request = + DeleteAllContextsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + deleteAllContexts(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes all active contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   contextsClient.deleteAllContexts(parent.toString());
+   * }
+   * 
+ * + * @param parent Required. The name of the session to delete all contexts from. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteAllContexts(String parent) { + + DeleteAllContextsRequest request = + DeleteAllContextsRequest.newBuilder().setParent(parent).build(); + deleteAllContexts(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes all active contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   DeleteAllContextsRequest request = DeleteAllContextsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   contextsClient.deleteAllContexts(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final void deleteAllContexts(DeleteAllContextsRequest request) { + deleteAllContextsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes all active contexts in the specified session. + * + *

Sample code: + * + *


+   * try (ContextsClient contextsClient = ContextsClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   DeleteAllContextsRequest request = DeleteAllContextsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<Void> future = contextsClient.deleteAllContextsCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteAllContextsCallable() { + return stub.deleteAllContextsCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListContextsPagedResponse + extends AbstractPagedListResponse< + ListContextsRequest, ListContextsResponse, Context, ListContextsPage, + ListContextsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListContextsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListContextsPagedResponse apply(ListContextsPage input) { + return new ListContextsPagedResponse(input); + } + }); + } + + private ListContextsPagedResponse(ListContextsPage page) { + super(page, ListContextsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListContextsPage + extends AbstractPage { + + private ListContextsPage( + PageContext context, + ListContextsResponse response) { + super(context, response); + } + + private static ListContextsPage createEmptyPage() { + return new ListContextsPage(null, null); + } + + @Override + protected ListContextsPage createPage( + PageContext context, + ListContextsResponse response) { + return new ListContextsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListContextsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListContextsRequest, ListContextsResponse, Context, ListContextsPage, + ListContextsFixedSizeCollection> { + + private ListContextsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListContextsFixedSizeCollection createEmptyCollection() { + return new ListContextsFixedSizeCollection(null, 0); + } + + @Override + protected ListContextsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListContextsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java new file mode 100644 index 000000000000..8eece9b88bce --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/ContextsSettings.java @@ -0,0 +1,230 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.dialogflow.v2.stub.ContextsStubSettings; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link ContextsClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getContext to 30 seconds: + * + *

+ * 
+ * ContextsSettings.Builder contextsSettingsBuilder =
+ *     ContextsSettings.newBuilder();
+ * contextsSettingsBuilder.getContextSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * ContextsSettings contextsSettings = contextsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class ContextsSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listContexts. */ + public PagedCallSettings + listContextsSettings() { + return ((ContextsStubSettings) getStubSettings()).listContextsSettings(); + } + + /** Returns the object with the settings used for calls to getContext. */ + public UnaryCallSettings getContextSettings() { + return ((ContextsStubSettings) getStubSettings()).getContextSettings(); + } + + /** Returns the object with the settings used for calls to createContext. */ + public UnaryCallSettings createContextSettings() { + return ((ContextsStubSettings) getStubSettings()).createContextSettings(); + } + + /** Returns the object with the settings used for calls to updateContext. */ + public UnaryCallSettings updateContextSettings() { + return ((ContextsStubSettings) getStubSettings()).updateContextSettings(); + } + + /** Returns the object with the settings used for calls to deleteContext. */ + public UnaryCallSettings deleteContextSettings() { + return ((ContextsStubSettings) getStubSettings()).deleteContextSettings(); + } + + /** Returns the object with the settings used for calls to deleteAllContexts. */ + public UnaryCallSettings deleteAllContextsSettings() { + return ((ContextsStubSettings) getStubSettings()).deleteAllContextsSettings(); + } + + public static final ContextsSettings create(ContextsStubSettings stub) throws IOException { + return new ContextsSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return ContextsStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return ContextsStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return ContextsStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return ContextsStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return ContextsStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return ContextsStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ContextsStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected ContextsSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for ContextsSettings. */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(ContextsStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(ContextsStubSettings.newBuilder()); + } + + protected Builder(ContextsSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(ContextsStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public ContextsStubSettings.Builder getStubSettingsBuilder() { + return ((ContextsStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to listContexts. */ + public PagedCallSettings.Builder< + ListContextsRequest, ListContextsResponse, ListContextsPagedResponse> + listContextsSettings() { + return getStubSettingsBuilder().listContextsSettings(); + } + + /** Returns the builder for the settings used for calls to getContext. */ + public UnaryCallSettings.Builder getContextSettings() { + return getStubSettingsBuilder().getContextSettings(); + } + + /** Returns the builder for the settings used for calls to createContext. */ + public UnaryCallSettings.Builder createContextSettings() { + return getStubSettingsBuilder().createContextSettings(); + } + + /** Returns the builder for the settings used for calls to updateContext. */ + public UnaryCallSettings.Builder updateContextSettings() { + return getStubSettingsBuilder().updateContextSettings(); + } + + /** Returns the builder for the settings used for calls to deleteContext. */ + public UnaryCallSettings.Builder deleteContextSettings() { + return getStubSettingsBuilder().deleteContextSettings(); + } + + /** Returns the builder for the settings used for calls to deleteAllContexts. */ + public UnaryCallSettings.Builder deleteAllContextsSettings() { + return getStubSettingsBuilder().deleteAllContextsSettings(); + } + + @Override + public ContextsSettings build() throws IOException { + return new ContextsSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java new file mode 100644 index 000000000000..ff30c089472d --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesClient.java @@ -0,0 +1,1937 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.EntityType.Entity; +import com.google.cloud.dialogflow.v2.stub.EntityTypesStub; +import com.google.cloud.dialogflow.v2.stub.EntityTypesStubSettings; +import com.google.longrunning.Operation; +import com.google.longrunning.OperationsClient; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: Entities are extracted from user input and represent parameters that are + * meaningful to your application. For example, a date range, a proper name such as a geographic + * location or landmark, and so on. Entities represent actionable data for your application. + * + *

When you define an entity, you can also include synonyms that all map to that entity. For + * example, "soft drink", "soda", "pop", and so on. + * + *

There are three types of entities: + * + *

* **System** - entities that are defined by the Dialogflow API for common + * data types such as date, time, currency, and so on. A system entity is represented by the + * `EntityType` type. + * + *

* **Developer** - entities that are defined by you that represent + * actionable data that is meaningful to your application. For example, you could define a + * `pizza.sauce` entity for red or white pizza sauce, a `pizza.cheese` entity for the different + * types of cheese on a pizza, a `pizza.topping` entity for different toppings, and so on. A + * developer entity is represented by the `EntityType` type. + * + *

* **User** - entities that are built for an individual user such as + * favorites, preferences, playlists, and so on. A user entity is represented by the + * [SessionEntityType][google.cloud.dialogflow.v2.SessionEntityType] type. + * + *

For more information about entity types, see the [Dialogflow + * documentation](https://dialogflow.com/docs/entities). + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+ *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+ *   EntityType response = entityTypesClient.getEntityType(name);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the entityTypesClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of EntityTypesSettings to + * create(). For example: + * + *

To customize credentials: + * + *

+ * 
+ * EntityTypesSettings entityTypesSettings =
+ *     EntityTypesSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * EntityTypesClient entityTypesClient =
+ *     EntityTypesClient.create(entityTypesSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * EntityTypesSettings entityTypesSettings =
+ *     EntityTypesSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * EntityTypesClient entityTypesClient =
+ *     EntityTypesClient.create(entityTypesSettings);
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class EntityTypesClient implements BackgroundResource { + private final EntityTypesSettings settings; + private final EntityTypesStub stub; + private final OperationsClient operationsClient; + + /** Constructs an instance of EntityTypesClient with default settings. */ + public static final EntityTypesClient create() throws IOException { + return create(EntityTypesSettings.newBuilder().build()); + } + + /** + * Constructs an instance of EntityTypesClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final EntityTypesClient create(EntityTypesSettings settings) throws IOException { + return new EntityTypesClient(settings); + } + + /** + * Constructs an instance of EntityTypesClient, using the given stub for making calls. This is for + * advanced usage - prefer to use EntityTypesSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final EntityTypesClient create(EntityTypesStub stub) { + return new EntityTypesClient(stub); + } + + /** + * Constructs an instance of EntityTypesClient, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected EntityTypesClient(EntityTypesSettings settings) throws IOException { + this.settings = settings; + this.stub = ((EntityTypesStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected EntityTypesClient(EntityTypesStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + public final EntityTypesSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public EntityTypesStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getOperationsClient() { + return operationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all entity types in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   for (EntityType element : entityTypesClient.listEntityTypes(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all entity types from. Format: `projects/<Project + * ID>/agent`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListEntityTypesPagedResponse listEntityTypes(ProjectAgentName parent) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listEntityTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all entity types in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   for (EntityType element : entityTypesClient.listEntityTypes(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all entity types from. Format: `projects/<Project + * ID>/agent`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListEntityTypesPagedResponse listEntityTypes(String parent) { + ListEntityTypesRequest request = ListEntityTypesRequest.newBuilder().setParent(parent).build(); + return listEntityTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all entity types in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   String languageCode = "";
+   *   for (EntityType element : entityTypesClient.listEntityTypes(parent, languageCode).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all entity types from. Format: `projects/<Project + * ID>/agent`. + * @param languageCode Optional. The language to list entity synonyms for. If not specified, the + * agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListEntityTypesPagedResponse listEntityTypes( + ProjectAgentName parent, String languageCode) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setLanguageCode(languageCode) + .build(); + return listEntityTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all entity types in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   String languageCode = "";
+   *   for (EntityType element : entityTypesClient.listEntityTypes(parent.toString(), languageCode).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all entity types from. Format: `projects/<Project + * ID>/agent`. + * @param languageCode Optional. The language to list entity synonyms for. If not specified, the + * agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListEntityTypesPagedResponse listEntityTypes(String parent, String languageCode) { + ListEntityTypesRequest request = + ListEntityTypesRequest.newBuilder().setParent(parent).setLanguageCode(languageCode).build(); + return listEntityTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all entity types in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   ListEntityTypesRequest request = ListEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (EntityType element : entityTypesClient.listEntityTypes(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListEntityTypesPagedResponse listEntityTypes(ListEntityTypesRequest request) { + return listEntityTypesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all entity types in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   ListEntityTypesRequest request = ListEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListEntityTypesPagedResponse> future = entityTypesClient.listEntityTypesPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (EntityType element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listEntityTypesPagedCallable() { + return stub.listEntityTypesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all entity types in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   ListEntityTypesRequest request = ListEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListEntityTypesResponse response = entityTypesClient.listEntityTypesCallable().call(request);
+   *     for (EntityType element : response.getEntityTypesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listEntityTypesCallable() { + return stub.listEntityTypesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   EntityType response = entityTypesClient.getEntityType(name);
+   * }
+   * 
+ * + * @param name Required. The name of the entity type. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType getEntityType(EntityTypeName name) { + + GetEntityTypeRequest request = + GetEntityTypeRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   EntityType response = entityTypesClient.getEntityType(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the entity type. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType getEntityType(String name) { + + GetEntityTypeRequest request = GetEntityTypeRequest.newBuilder().setName(name).build(); + return getEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   String languageCode = "";
+   *   EntityType response = entityTypesClient.getEntityType(name, languageCode);
+   * }
+   * 
+ * + * @param name Required. The name of the entity type. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @param languageCode Optional. The language to retrieve entity synonyms for. If not specified, + * the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType getEntityType(EntityTypeName name, String languageCode) { + + GetEntityTypeRequest request = + GetEntityTypeRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setLanguageCode(languageCode) + .build(); + return getEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   String languageCode = "";
+   *   EntityType response = entityTypesClient.getEntityType(name.toString(), languageCode);
+   * }
+   * 
+ * + * @param name Required. The name of the entity type. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @param languageCode Optional. The language to retrieve entity synonyms for. If not specified, + * the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType getEntityType(String name, String languageCode) { + + GetEntityTypeRequest request = + GetEntityTypeRequest.newBuilder().setName(name).setLanguageCode(languageCode).build(); + return getEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   GetEntityTypeRequest request = GetEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   EntityType response = entityTypesClient.getEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType getEntityType(GetEntityTypeRequest request) { + return getEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   GetEntityTypeRequest request = GetEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<EntityType> future = entityTypesClient.getEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   EntityType response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getEntityTypeCallable() { + return stub.getEntityTypeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an entity type in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   EntityType response = entityTypesClient.createEntityType(parent, entityType);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a entity type for. Format: `projects/<Project + * ID>/agent`. + * @param entityType Required. The entity type to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType createEntityType(ProjectAgentName parent, EntityType entityType) { + + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setEntityType(entityType) + .build(); + return createEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an entity type in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   EntityType response = entityTypesClient.createEntityType(parent.toString(), entityType);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a entity type for. Format: `projects/<Project + * ID>/agent`. + * @param entityType Required. The entity type to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType createEntityType(String parent, EntityType entityType) { + + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder().setParent(parent).setEntityType(entityType).build(); + return createEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an entity type in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   String languageCode = "";
+   *   EntityType response = entityTypesClient.createEntityType(parent, entityType, languageCode);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a entity type for. Format: `projects/<Project + * ID>/agent`. + * @param entityType Required. The entity type to create. + * @param languageCode Optional. The language of entity synonyms defined in `entity_type`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType createEntityType( + ProjectAgentName parent, EntityType entityType, String languageCode) { + + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setEntityType(entityType) + .setLanguageCode(languageCode) + .build(); + return createEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an entity type in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   String languageCode = "";
+   *   EntityType response = entityTypesClient.createEntityType(parent.toString(), entityType, languageCode);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a entity type for. Format: `projects/<Project + * ID>/agent`. + * @param entityType Required. The entity type to create. + * @param languageCode Optional. The language of entity synonyms defined in `entity_type`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType createEntityType( + String parent, EntityType entityType, String languageCode) { + + CreateEntityTypeRequest request = + CreateEntityTypeRequest.newBuilder() + .setParent(parent) + .setEntityType(entityType) + .setLanguageCode(languageCode) + .build(); + return createEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an entity type in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   CreateEntityTypeRequest request = CreateEntityTypeRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setEntityType(entityType)
+   *     .build();
+   *   EntityType response = entityTypesClient.createEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType createEntityType(CreateEntityTypeRequest request) { + return createEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an entity type in the specified agent. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   CreateEntityTypeRequest request = CreateEntityTypeRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setEntityType(entityType)
+   *     .build();
+   *   ApiFuture<EntityType> future = entityTypesClient.createEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   EntityType response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createEntityTypeCallable() { + return stub.createEntityTypeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   EntityType response = entityTypesClient.updateEntityType(entityType);
+   * }
+   * 
+ * + * @param entityType Required. The entity type to update. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType updateEntityType(EntityType entityType) { + + UpdateEntityTypeRequest request = + UpdateEntityTypeRequest.newBuilder().setEntityType(entityType).build(); + return updateEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   String languageCode = "";
+   *   EntityType response = entityTypesClient.updateEntityType(entityType, languageCode);
+   * }
+   * 
+ * + * @param entityType Required. The entity type to update. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @param languageCode Optional. The language of entity synonyms defined in `entity_type`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType updateEntityType(EntityType entityType, String languageCode) { + + UpdateEntityTypeRequest request = + UpdateEntityTypeRequest.newBuilder() + .setEntityType(entityType) + .setLanguageCode(languageCode) + .build(); + return updateEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   UpdateEntityTypeRequest request = UpdateEntityTypeRequest.newBuilder()
+   *     .setEntityType(entityType)
+   *     .build();
+   *   EntityType response = entityTypesClient.updateEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EntityType updateEntityType(UpdateEntityTypeRequest request) { + return updateEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityType entityType = EntityType.newBuilder().build();
+   *   UpdateEntityTypeRequest request = UpdateEntityTypeRequest.newBuilder()
+   *     .setEntityType(entityType)
+   *     .build();
+   *   ApiFuture<EntityType> future = entityTypesClient.updateEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   EntityType response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable updateEntityTypeCallable() { + return stub.updateEntityTypeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   entityTypesClient.deleteEntityType(name);
+   * }
+   * 
+ * + * @param name Required. The name of the entity type to delete. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteEntityType(EntityTypeName name) { + + DeleteEntityTypeRequest request = + DeleteEntityTypeRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   entityTypesClient.deleteEntityType(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the entity type to delete. Format: `projects/<Project + * ID>/agent/entityTypes/<EntityType ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteEntityType(String name) { + + DeleteEntityTypeRequest request = DeleteEntityTypeRequest.newBuilder().setName(name).build(); + deleteEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   DeleteEntityTypeRequest request = DeleteEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   entityTypesClient.deleteEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final void deleteEntityType(DeleteEntityTypeRequest request) { + deleteEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified entity type. + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   DeleteEntityTypeRequest request = DeleteEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = entityTypesClient.deleteEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteEntityTypeCallable() { + return stub.deleteEntityTypeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates/Creates multiple entity types in the specified agent. + * + *

Operation <response: + * [BatchUpdateEntityTypesResponse][google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse], + * metadata: [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   BatchUpdateEntityTypesRequest request = BatchUpdateEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   BatchUpdateEntityTypesResponse response = entityTypesClient.batchUpdateEntityTypesAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchUpdateEntityTypesAsync( + BatchUpdateEntityTypesRequest request) { + return batchUpdateEntityTypesOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates/Creates multiple entity types in the specified agent. + * + *

Operation <response: + * [BatchUpdateEntityTypesResponse][google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse], + * metadata: [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   BatchUpdateEntityTypesRequest request = BatchUpdateEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   OperationFuture<Operation> future = entityTypesClient.batchUpdateEntityTypesOperationCallable().futureCall(request);
+   *   // Do something
+   *   BatchUpdateEntityTypesResponse response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationCallable() { + return stub.batchUpdateEntityTypesOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates/Creates multiple entity types in the specified agent. + * + *

Operation <response: + * [BatchUpdateEntityTypesResponse][google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse], + * metadata: [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   BatchUpdateEntityTypesRequest request = BatchUpdateEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = entityTypesClient.batchUpdateEntityTypesCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + batchUpdateEntityTypesCallable() { + return stub.batchUpdateEntityTypesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entity types in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<String> entityTypeNames = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchDeleteEntityTypesAsync(parent, entityTypeNames).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the agent to delete all entities types for. Format: + * `projects/<Project ID>/agent`. + * @param entityTypeNames Required. The names entity types to delete. All names must point to the + * same agent as `parent`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntityTypesAsync( + ProjectAgentName parent, List entityTypeNames) { + + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllEntityTypeNames(entityTypeNames) + .build(); + return batchDeleteEntityTypesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entity types in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<String> entityTypeNames = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchDeleteEntityTypesAsync(parent.toString(), entityTypeNames).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the agent to delete all entities types for. Format: + * `projects/<Project ID>/agent`. + * @param entityTypeNames Required. The names entity types to delete. All names must point to the + * same agent as `parent`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntityTypesAsync( + String parent, List entityTypeNames) { + + BatchDeleteEntityTypesRequest request = + BatchDeleteEntityTypesRequest.newBuilder() + .setParent(parent) + .addAllEntityTypeNames(entityTypeNames) + .build(); + return batchDeleteEntityTypesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entity types in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<String> entityTypeNames = new ArrayList<>();
+   *   BatchDeleteEntityTypesRequest request = BatchDeleteEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntityTypeNames(entityTypeNames)
+   *     .build();
+   *   Empty response = entityTypesClient.batchDeleteEntityTypesAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntityTypesAsync( + BatchDeleteEntityTypesRequest request) { + return batchDeleteEntityTypesOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entity types in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<String> entityTypeNames = new ArrayList<>();
+   *   BatchDeleteEntityTypesRequest request = BatchDeleteEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntityTypeNames(entityTypeNames)
+   *     .build();
+   *   OperationFuture<Operation> future = entityTypesClient.batchDeleteEntityTypesOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + batchDeleteEntityTypesOperationCallable() { + return stub.batchDeleteEntityTypesOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entity types in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<String> entityTypeNames = new ArrayList<>();
+   *   BatchDeleteEntityTypesRequest request = BatchDeleteEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntityTypeNames(entityTypeNames)
+   *     .build();
+   *   ApiFuture<Operation> future = entityTypesClient.batchDeleteEntityTypesCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + batchDeleteEntityTypesCallable() { + return stub.batchDeleteEntityTypesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates multiple new entities in the specified entity type (extends the existing collection of + * entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchCreateEntitiesAsync(parent, entities).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to create entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of entities to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchCreateEntitiesAsync( + EntityTypeName parent, List entities) { + + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllEntities(entities) + .build(); + return batchCreateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates multiple new entities in the specified entity type (extends the existing collection of + * entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchCreateEntitiesAsync(parent.toString(), entities).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to create entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of entities to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchCreateEntitiesAsync( + String parent, List entities) { + + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder().setParent(parent).addAllEntities(entities).build(); + return batchCreateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates multiple new entities in the specified entity type (extends the existing collection of + * entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   String languageCode = "";
+   *   Empty response = entityTypesClient.batchCreateEntitiesAsync(parent, entities, languageCode).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to create entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of entities to create. + * @param languageCode Optional. The language of entity synonyms defined in `entities`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchCreateEntitiesAsync( + EntityTypeName parent, List entities, String languageCode) { + + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllEntities(entities) + .setLanguageCode(languageCode) + .build(); + return batchCreateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates multiple new entities in the specified entity type (extends the existing collection of + * entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   String languageCode = "";
+   *   Empty response = entityTypesClient.batchCreateEntitiesAsync(parent.toString(), entities, languageCode).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to create entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of entities to create. + * @param languageCode Optional. The language of entity synonyms defined in `entities`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchCreateEntitiesAsync( + String parent, List entities, String languageCode) { + + BatchCreateEntitiesRequest request = + BatchCreateEntitiesRequest.newBuilder() + .setParent(parent) + .addAllEntities(entities) + .setLanguageCode(languageCode) + .build(); + return batchCreateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates multiple new entities in the specified entity type (extends the existing collection of + * entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   BatchCreateEntitiesRequest request = BatchCreateEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntities(entities)
+   *     .build();
+   *   Empty response = entityTypesClient.batchCreateEntitiesAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchCreateEntitiesAsync( + BatchCreateEntitiesRequest request) { + return batchCreateEntitiesOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates multiple new entities in the specified entity type (extends the existing collection of + * entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   BatchCreateEntitiesRequest request = BatchCreateEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntities(entities)
+   *     .build();
+   *   OperationFuture<Operation> future = entityTypesClient.batchCreateEntitiesOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + batchCreateEntitiesOperationCallable() { + return stub.batchCreateEntitiesOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates multiple new entities in the specified entity type (extends the existing collection of + * entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   BatchCreateEntitiesRequest request = BatchCreateEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntities(entities)
+   *     .build();
+   *   ApiFuture<Operation> future = entityTypesClient.batchCreateEntitiesCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable batchCreateEntitiesCallable() { + return stub.batchCreateEntitiesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates entities in the specified entity type (replaces the existing collection of entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchUpdateEntitiesAsync(parent, entities).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to update the entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of new entities to replace the existing entities. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchUpdateEntitiesAsync( + EntityTypeName parent, List entities) { + + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllEntities(entities) + .build(); + return batchUpdateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates entities in the specified entity type (replaces the existing collection of entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchUpdateEntitiesAsync(parent.toString(), entities).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to update the entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of new entities to replace the existing entities. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchUpdateEntitiesAsync( + String parent, List entities) { + + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder().setParent(parent).addAllEntities(entities).build(); + return batchUpdateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates entities in the specified entity type (replaces the existing collection of entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   String languageCode = "";
+   *   Empty response = entityTypesClient.batchUpdateEntitiesAsync(parent, entities, languageCode).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to update the entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of new entities to replace the existing entities. + * @param languageCode Optional. The language of entity synonyms defined in `entities`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchUpdateEntitiesAsync( + EntityTypeName parent, List entities, String languageCode) { + + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllEntities(entities) + .setLanguageCode(languageCode) + .build(); + return batchUpdateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates entities in the specified entity type (replaces the existing collection of entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   String languageCode = "";
+   *   Empty response = entityTypesClient.batchUpdateEntitiesAsync(parent.toString(), entities, languageCode).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to update the entities in. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entities Required. The collection of new entities to replace the existing entities. + * @param languageCode Optional. The language of entity synonyms defined in `entities`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchUpdateEntitiesAsync( + String parent, List entities, String languageCode) { + + BatchUpdateEntitiesRequest request = + BatchUpdateEntitiesRequest.newBuilder() + .setParent(parent) + .addAllEntities(entities) + .setLanguageCode(languageCode) + .build(); + return batchUpdateEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates entities in the specified entity type (replaces the existing collection of entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   BatchUpdateEntitiesRequest request = BatchUpdateEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntities(entities)
+   *     .build();
+   *   Empty response = entityTypesClient.batchUpdateEntitiesAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchUpdateEntitiesAsync( + BatchUpdateEntitiesRequest request) { + return batchUpdateEntitiesOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates entities in the specified entity type (replaces the existing collection of entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   BatchUpdateEntitiesRequest request = BatchUpdateEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntities(entities)
+   *     .build();
+   *   OperationFuture<Operation> future = entityTypesClient.batchUpdateEntitiesOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + batchUpdateEntitiesOperationCallable() { + return stub.batchUpdateEntitiesOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates entities in the specified entity type (replaces the existing collection of entries). + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<EntityType.Entity> entities = new ArrayList<>();
+   *   BatchUpdateEntitiesRequest request = BatchUpdateEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntities(entities)
+   *     .build();
+   *   ApiFuture<Operation> future = entityTypesClient.batchUpdateEntitiesCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable batchUpdateEntitiesCallable() { + return stub.batchUpdateEntitiesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entities in the specified entity type. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<String> entityValues = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to delete entries for. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entityValues Required. The canonical `values` of the entities to delete. Note that these + * are not fully-qualified names, i.e. they don't start with `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntitiesAsync( + EntityTypeName parent, List entityValues) { + + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllEntityValues(entityValues) + .build(); + return batchDeleteEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entities in the specified entity type. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<String> entityValues = new ArrayList<>();
+   *   Empty response = entityTypesClient.batchDeleteEntitiesAsync(parent.toString(), entityValues).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to delete entries for. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entityValues Required. The canonical `values` of the entities to delete. Note that these + * are not fully-qualified names, i.e. they don't start with `projects/<Project ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntitiesAsync( + String parent, List entityValues) { + + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent(parent) + .addAllEntityValues(entityValues) + .build(); + return batchDeleteEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entities in the specified entity type. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<String> entityValues = new ArrayList<>();
+   *   String languageCode = "";
+   *   Empty response = entityTypesClient.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to delete entries for. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entityValues Required. The canonical `values` of the entities to delete. Note that these + * are not fully-qualified names, i.e. they don't start with `projects/<Project ID>`. + * @param languageCode Optional. The language of entity synonyms defined in `entities`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntitiesAsync( + EntityTypeName parent, List entityValues, String languageCode) { + + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllEntityValues(entityValues) + .setLanguageCode(languageCode) + .build(); + return batchDeleteEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entities in the specified entity type. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<String> entityValues = new ArrayList<>();
+   *   String languageCode = "";
+   *   Empty response = entityTypesClient.batchDeleteEntitiesAsync(parent.toString(), entityValues, languageCode).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the entity type to delete entries for. Format: + * `projects/<Project ID>/agent/entityTypes/<Entity Type ID>`. + * @param entityValues Required. The canonical `values` of the entities to delete. Note that these + * are not fully-qualified names, i.e. they don't start with `projects/<Project ID>`. + * @param languageCode Optional. The language of entity synonyms defined in `entities`. If not + * specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntitiesAsync( + String parent, List entityValues, String languageCode) { + + BatchDeleteEntitiesRequest request = + BatchDeleteEntitiesRequest.newBuilder() + .setParent(parent) + .addAllEntityValues(entityValues) + .setLanguageCode(languageCode) + .build(); + return batchDeleteEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entities in the specified entity type. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<String> entityValues = new ArrayList<>();
+   *   BatchDeleteEntitiesRequest request = BatchDeleteEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntityValues(entityValues)
+   *     .build();
+   *   Empty response = entityTypesClient.batchDeleteEntitiesAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteEntitiesAsync( + BatchDeleteEntitiesRequest request) { + return batchDeleteEntitiesOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entities in the specified entity type. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<String> entityValues = new ArrayList<>();
+   *   BatchDeleteEntitiesRequest request = BatchDeleteEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntityValues(entityValues)
+   *     .build();
+   *   OperationFuture<Operation> future = entityTypesClient.batchDeleteEntitiesOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + batchDeleteEntitiesOperationCallable() { + return stub.batchDeleteEntitiesOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes entities in the specified entity type. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty], metadata: + * [google.protobuf.Struct][google.protobuf.Struct]> + * + *

Sample code: + * + *


+   * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+   *   EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+   *   List<String> entityValues = new ArrayList<>();
+   *   BatchDeleteEntitiesRequest request = BatchDeleteEntitiesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllEntityValues(entityValues)
+   *     .build();
+   *   ApiFuture<Operation> future = entityTypesClient.batchDeleteEntitiesCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable batchDeleteEntitiesCallable() { + return stub.batchDeleteEntitiesCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListEntityTypesPagedResponse + extends AbstractPagedListResponse< + ListEntityTypesRequest, ListEntityTypesResponse, EntityType, ListEntityTypesPage, + ListEntityTypesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListEntityTypesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListEntityTypesPagedResponse apply(ListEntityTypesPage input) { + return new ListEntityTypesPagedResponse(input); + } + }); + } + + private ListEntityTypesPagedResponse(ListEntityTypesPage page) { + super(page, ListEntityTypesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListEntityTypesPage + extends AbstractPage< + ListEntityTypesRequest, ListEntityTypesResponse, EntityType, ListEntityTypesPage> { + + private ListEntityTypesPage( + PageContext context, + ListEntityTypesResponse response) { + super(context, response); + } + + private static ListEntityTypesPage createEmptyPage() { + return new ListEntityTypesPage(null, null); + } + + @Override + protected ListEntityTypesPage createPage( + PageContext context, + ListEntityTypesResponse response) { + return new ListEntityTypesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListEntityTypesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListEntityTypesRequest, ListEntityTypesResponse, EntityType, ListEntityTypesPage, + ListEntityTypesFixedSizeCollection> { + + private ListEntityTypesFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListEntityTypesFixedSizeCollection createEmptyCollection() { + return new ListEntityTypesFixedSizeCollection(null, 0); + } + + @Override + protected ListEntityTypesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListEntityTypesFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java new file mode 100644 index 000000000000..90f5249cf730 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/EntityTypesSettings.java @@ -0,0 +1,345 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.EntityTypesClient.ListEntityTypesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.dialogflow.v2.stub.EntityTypesStubSettings; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link EntityTypesClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getEntityType to 30 seconds: + * + *

+ * 
+ * EntityTypesSettings.Builder entityTypesSettingsBuilder =
+ *     EntityTypesSettings.newBuilder();
+ * entityTypesSettingsBuilder.getEntityTypeSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * EntityTypesSettings entityTypesSettings = entityTypesSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class EntityTypesSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listEntityTypes. */ + public PagedCallSettings< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse> + listEntityTypesSettings() { + return ((EntityTypesStubSettings) getStubSettings()).listEntityTypesSettings(); + } + + /** Returns the object with the settings used for calls to getEntityType. */ + public UnaryCallSettings getEntityTypeSettings() { + return ((EntityTypesStubSettings) getStubSettings()).getEntityTypeSettings(); + } + + /** Returns the object with the settings used for calls to createEntityType. */ + public UnaryCallSettings createEntityTypeSettings() { + return ((EntityTypesStubSettings) getStubSettings()).createEntityTypeSettings(); + } + + /** Returns the object with the settings used for calls to updateEntityType. */ + public UnaryCallSettings updateEntityTypeSettings() { + return ((EntityTypesStubSettings) getStubSettings()).updateEntityTypeSettings(); + } + + /** Returns the object with the settings used for calls to deleteEntityType. */ + public UnaryCallSettings deleteEntityTypeSettings() { + return ((EntityTypesStubSettings) getStubSettings()).deleteEntityTypeSettings(); + } + + /** Returns the object with the settings used for calls to batchUpdateEntityTypes. */ + public UnaryCallSettings + batchUpdateEntityTypesSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchUpdateEntityTypesSettings(); + } + + /** Returns the object with the settings used for calls to batchUpdateEntityTypes. */ + public OperationCallSettings< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchUpdateEntityTypesOperationSettings(); + } + + /** Returns the object with the settings used for calls to batchDeleteEntityTypes. */ + public UnaryCallSettings + batchDeleteEntityTypesSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchDeleteEntityTypesSettings(); + } + + /** Returns the object with the settings used for calls to batchDeleteEntityTypes. */ + public OperationCallSettings + batchDeleteEntityTypesOperationSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchDeleteEntityTypesOperationSettings(); + } + + /** Returns the object with the settings used for calls to batchCreateEntities. */ + public UnaryCallSettings batchCreateEntitiesSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchCreateEntitiesSettings(); + } + + /** Returns the object with the settings used for calls to batchCreateEntities. */ + public OperationCallSettings + batchCreateEntitiesOperationSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchCreateEntitiesOperationSettings(); + } + + /** Returns the object with the settings used for calls to batchUpdateEntities. */ + public UnaryCallSettings batchUpdateEntitiesSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchUpdateEntitiesSettings(); + } + + /** Returns the object with the settings used for calls to batchUpdateEntities. */ + public OperationCallSettings + batchUpdateEntitiesOperationSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchUpdateEntitiesOperationSettings(); + } + + /** Returns the object with the settings used for calls to batchDeleteEntities. */ + public UnaryCallSettings batchDeleteEntitiesSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchDeleteEntitiesSettings(); + } + + /** Returns the object with the settings used for calls to batchDeleteEntities. */ + public OperationCallSettings + batchDeleteEntitiesOperationSettings() { + return ((EntityTypesStubSettings) getStubSettings()).batchDeleteEntitiesOperationSettings(); + } + + public static final EntityTypesSettings create(EntityTypesStubSettings stub) throws IOException { + return new EntityTypesSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return EntityTypesStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return EntityTypesStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return EntityTypesStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return EntityTypesStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return EntityTypesStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return EntityTypesStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return EntityTypesStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected EntityTypesSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for EntityTypesSettings. */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(EntityTypesStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(EntityTypesStubSettings.newBuilder()); + } + + protected Builder(EntityTypesSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(EntityTypesStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public EntityTypesStubSettings.Builder getStubSettingsBuilder() { + return ((EntityTypesStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to listEntityTypes. */ + public PagedCallSettings.Builder< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse> + listEntityTypesSettings() { + return getStubSettingsBuilder().listEntityTypesSettings(); + } + + /** Returns the builder for the settings used for calls to getEntityType. */ + public UnaryCallSettings.Builder getEntityTypeSettings() { + return getStubSettingsBuilder().getEntityTypeSettings(); + } + + /** Returns the builder for the settings used for calls to createEntityType. */ + public UnaryCallSettings.Builder + createEntityTypeSettings() { + return getStubSettingsBuilder().createEntityTypeSettings(); + } + + /** Returns the builder for the settings used for calls to updateEntityType. */ + public UnaryCallSettings.Builder + updateEntityTypeSettings() { + return getStubSettingsBuilder().updateEntityTypeSettings(); + } + + /** Returns the builder for the settings used for calls to deleteEntityType. */ + public UnaryCallSettings.Builder deleteEntityTypeSettings() { + return getStubSettingsBuilder().deleteEntityTypeSettings(); + } + + /** Returns the builder for the settings used for calls to batchUpdateEntityTypes. */ + public UnaryCallSettings.Builder + batchUpdateEntityTypesSettings() { + return getStubSettingsBuilder().batchUpdateEntityTypesSettings(); + } + + /** Returns the builder for the settings used for calls to batchUpdateEntityTypes. */ + public OperationCallSettings.Builder< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationSettings() { + return getStubSettingsBuilder().batchUpdateEntityTypesOperationSettings(); + } + + /** Returns the builder for the settings used for calls to batchDeleteEntityTypes. */ + public UnaryCallSettings.Builder + batchDeleteEntityTypesSettings() { + return getStubSettingsBuilder().batchDeleteEntityTypesSettings(); + } + + /** Returns the builder for the settings used for calls to batchDeleteEntityTypes. */ + public OperationCallSettings.Builder + batchDeleteEntityTypesOperationSettings() { + return getStubSettingsBuilder().batchDeleteEntityTypesOperationSettings(); + } + + /** Returns the builder for the settings used for calls to batchCreateEntities. */ + public UnaryCallSettings.Builder + batchCreateEntitiesSettings() { + return getStubSettingsBuilder().batchCreateEntitiesSettings(); + } + + /** Returns the builder for the settings used for calls to batchCreateEntities. */ + public OperationCallSettings.Builder + batchCreateEntitiesOperationSettings() { + return getStubSettingsBuilder().batchCreateEntitiesOperationSettings(); + } + + /** Returns the builder for the settings used for calls to batchUpdateEntities. */ + public UnaryCallSettings.Builder + batchUpdateEntitiesSettings() { + return getStubSettingsBuilder().batchUpdateEntitiesSettings(); + } + + /** Returns the builder for the settings used for calls to batchUpdateEntities. */ + public OperationCallSettings.Builder + batchUpdateEntitiesOperationSettings() { + return getStubSettingsBuilder().batchUpdateEntitiesOperationSettings(); + } + + /** Returns the builder for the settings used for calls to batchDeleteEntities. */ + public UnaryCallSettings.Builder + batchDeleteEntitiesSettings() { + return getStubSettingsBuilder().batchDeleteEntitiesSettings(); + } + + /** Returns the builder for the settings used for calls to batchDeleteEntities. */ + public OperationCallSettings.Builder + batchDeleteEntitiesOperationSettings() { + return getStubSettingsBuilder().batchDeleteEntitiesOperationSettings(); + } + + @Override + public EntityTypesSettings build() throws IOException { + return new EntityTypesSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java new file mode 100644 index 000000000000..597e72704472 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsClient.java @@ -0,0 +1,1254 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.stub.IntentsStub; +import com.google.cloud.dialogflow.v2.stub.IntentsStubSettings; +import com.google.longrunning.Operation; +import com.google.longrunning.OperationsClient; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: An intent represents a mapping between input from a user and an action to be + * taken by your application. When you pass user input to the + * [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or + * [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) method, the + * Dialogflow API analyzes the input and searches for a matching intent. If no match is found, the + * Dialogflow API returns a fallback intent (`is_fallback` = true). + * + *

You can provide additional information for the Dialogflow API to use to match user input to an + * intent by adding the following to your intent. + * + *

* **Contexts** - provide additional context for intent analysis. For + * example, if an intent is related to an object in your application that plays music, you can + * provide a context to determine when to match the intent if the user input is “turn it off”. You + * can include a context that matches the intent when there is previous user input of "play music", + * and not when there is previous user input of "turn on the light". + * + *

* **Events** - allow for matching an intent by using an event name instead + * of user input. Your application can provide an event name and related parameters to the + * Dialogflow API to match an intent. For example, when your application starts, you can send a + * welcome event with a user name parameter to the Dialogflow API to match an intent with a + * personalized welcome message for the user. + * + *

* **Training phrases** - provide examples of user input to train the + * Dialogflow API agent to better match intents. + * + *

For more information about intents, see the [Dialogflow + * documentation](https://dialogflow.com/docs/intents). + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (IntentsClient intentsClient = IntentsClient.create()) {
+ *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+ *   Intent response = intentsClient.getIntent(name);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the intentsClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of IntentsSettings to create(). + * For example: + * + *

To customize credentials: + * + *

+ * 
+ * IntentsSettings intentsSettings =
+ *     IntentsSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * IntentsClient intentsClient =
+ *     IntentsClient.create(intentsSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * IntentsSettings intentsSettings =
+ *     IntentsSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * IntentsClient intentsClient =
+ *     IntentsClient.create(intentsSettings);
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class IntentsClient implements BackgroundResource { + private final IntentsSettings settings; + private final IntentsStub stub; + private final OperationsClient operationsClient; + + /** Constructs an instance of IntentsClient with default settings. */ + public static final IntentsClient create() throws IOException { + return create(IntentsSettings.newBuilder().build()); + } + + /** + * Constructs an instance of IntentsClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final IntentsClient create(IntentsSettings settings) throws IOException { + return new IntentsClient(settings); + } + + /** + * Constructs an instance of IntentsClient, using the given stub for making calls. This is for + * advanced usage - prefer to use IntentsSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final IntentsClient create(IntentsStub stub) { + return new IntentsClient(stub); + } + + /** + * Constructs an instance of IntentsClient, using the given settings. This is protected so that it + * is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected IntentsClient(IntentsSettings settings) throws IOException { + this.settings = settings; + this.stub = ((IntentsStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected IntentsClient(IntentsStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + public final IntentsSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public IntentsStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getOperationsClient() { + return operationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all intents in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   for (Intent element : intentsClient.listIntents(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all intents from. Format: `projects/<Project + * ID>/agent`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListIntentsPagedResponse listIntents(ProjectAgentName parent) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listIntents(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all intents in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   for (Intent element : intentsClient.listIntents(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all intents from. Format: `projects/<Project + * ID>/agent`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListIntentsPagedResponse listIntents(String parent) { + ListIntentsRequest request = ListIntentsRequest.newBuilder().setParent(parent).build(); + return listIntents(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all intents in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   String languageCode = "";
+   *   for (Intent element : intentsClient.listIntents(parent, languageCode).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all intents from. Format: `projects/<Project + * ID>/agent`. + * @param languageCode Optional. The language to list training phrases, parameters and rich + * messages for. If not specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListIntentsPagedResponse listIntents(ProjectAgentName parent, String languageCode) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setLanguageCode(languageCode) + .build(); + return listIntents(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all intents in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   String languageCode = "";
+   *   for (Intent element : intentsClient.listIntents(parent.toString(), languageCode).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The agent to list all intents from. Format: `projects/<Project + * ID>/agent`. + * @param languageCode Optional. The language to list training phrases, parameters and rich + * messages for. If not specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListIntentsPagedResponse listIntents(String parent, String languageCode) { + ListIntentsRequest request = + ListIntentsRequest.newBuilder().setParent(parent).setLanguageCode(languageCode).build(); + return listIntents(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all intents in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   ListIntentsRequest request = ListIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (Intent element : intentsClient.listIntents(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListIntentsPagedResponse listIntents(ListIntentsRequest request) { + return listIntentsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all intents in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   ListIntentsRequest request = ListIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListIntentsPagedResponse> future = intentsClient.listIntentsPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (Intent element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listIntentsPagedCallable() { + return stub.listIntentsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all intents in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   ListIntentsRequest request = ListIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListIntentsResponse response = intentsClient.listIntentsCallable().call(request);
+   *     for (Intent element : response.getIntentsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listIntentsCallable() { + return stub.listIntentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   Intent response = intentsClient.getIntent(name);
+   * }
+   * 
+ * + * @param name Required. The name of the intent. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent getIntent(IntentName name) { + + GetIntentRequest request = + GetIntentRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   Intent response = intentsClient.getIntent(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the intent. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent getIntent(String name) { + + GetIntentRequest request = GetIntentRequest.newBuilder().setName(name).build(); + return getIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   String languageCode = "";
+   *   Intent response = intentsClient.getIntent(name, languageCode);
+   * }
+   * 
+ * + * @param name Required. The name of the intent. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @param languageCode Optional. The language to retrieve training phrases, parameters and rich + * messages for. If not specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent getIntent(IntentName name, String languageCode) { + + GetIntentRequest request = + GetIntentRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setLanguageCode(languageCode) + .build(); + return getIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   String languageCode = "";
+   *   Intent response = intentsClient.getIntent(name.toString(), languageCode);
+   * }
+   * 
+ * + * @param name Required. The name of the intent. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @param languageCode Optional. The language to retrieve training phrases, parameters and rich + * messages for. If not specified, the agent's default language is used. [More than a dozen + * languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages + * must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent getIntent(String name, String languageCode) { + + GetIntentRequest request = + GetIntentRequest.newBuilder().setName(name).setLanguageCode(languageCode).build(); + return getIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   GetIntentRequest request = GetIntentRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   Intent response = intentsClient.getIntent(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent getIntent(GetIntentRequest request) { + return getIntentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   GetIntentRequest request = GetIntentRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Intent> future = intentsClient.getIntentCallable().futureCall(request);
+   *   // Do something
+   *   Intent response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getIntentCallable() { + return stub.getIntentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an intent in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   Intent intent = Intent.newBuilder().build();
+   *   Intent response = intentsClient.createIntent(parent, intent);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a intent for. Format: `projects/<Project + * ID>/agent`. + * @param intent Required. The intent to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent createIntent(ProjectAgentName parent, Intent intent) { + + CreateIntentRequest request = + CreateIntentRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setIntent(intent) + .build(); + return createIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an intent in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   Intent intent = Intent.newBuilder().build();
+   *   Intent response = intentsClient.createIntent(parent.toString(), intent);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a intent for. Format: `projects/<Project + * ID>/agent`. + * @param intent Required. The intent to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent createIntent(String parent, Intent intent) { + + CreateIntentRequest request = + CreateIntentRequest.newBuilder().setParent(parent).setIntent(intent).build(); + return createIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an intent in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   Intent intent = Intent.newBuilder().build();
+   *   String languageCode = "";
+   *   Intent response = intentsClient.createIntent(parent, intent, languageCode);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a intent for. Format: `projects/<Project + * ID>/agent`. + * @param intent Required. The intent to create. + * @param languageCode Optional. The language of training phrases, parameters and rich messages + * defined in `intent`. If not specified, the agent's default language is used. [More than a + * dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note: + * languages must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent createIntent(ProjectAgentName parent, Intent intent, String languageCode) { + + CreateIntentRequest request = + CreateIntentRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setIntent(intent) + .setLanguageCode(languageCode) + .build(); + return createIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an intent in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   Intent intent = Intent.newBuilder().build();
+   *   String languageCode = "";
+   *   Intent response = intentsClient.createIntent(parent.toString(), intent, languageCode);
+   * }
+   * 
+ * + * @param parent Required. The agent to create a intent for. Format: `projects/<Project + * ID>/agent`. + * @param intent Required. The intent to create. + * @param languageCode Optional. The language of training phrases, parameters and rich messages + * defined in `intent`. If not specified, the agent's default language is used. [More than a + * dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note: + * languages must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent createIntent(String parent, Intent intent, String languageCode) { + + CreateIntentRequest request = + CreateIntentRequest.newBuilder() + .setParent(parent) + .setIntent(intent) + .setLanguageCode(languageCode) + .build(); + return createIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an intent in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   Intent intent = Intent.newBuilder().build();
+   *   CreateIntentRequest request = CreateIntentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setIntent(intent)
+   *     .build();
+   *   Intent response = intentsClient.createIntent(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent createIntent(CreateIntentRequest request) { + return createIntentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an intent in the specified agent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   Intent intent = Intent.newBuilder().build();
+   *   CreateIntentRequest request = CreateIntentRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setIntent(intent)
+   *     .build();
+   *   ApiFuture<Intent> future = intentsClient.createIntentCallable().futureCall(request);
+   *   // Do something
+   *   Intent response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createIntentCallable() { + return stub.createIntentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   Intent intent = Intent.newBuilder().build();
+   *   String languageCode = "";
+   *   Intent response = intentsClient.updateIntent(intent, languageCode);
+   * }
+   * 
+ * + * @param intent Required. The intent to update. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @param languageCode Optional. The language of training phrases, parameters and rich messages + * defined in `intent`. If not specified, the agent's default language is used. [More than a + * dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note: + * languages must be enabled in the agent, before they can be used. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent updateIntent(Intent intent, String languageCode) { + + UpdateIntentRequest request = + UpdateIntentRequest.newBuilder().setIntent(intent).setLanguageCode(languageCode).build(); + return updateIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   Intent intent = Intent.newBuilder().build();
+   *   String languageCode = "";
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Intent response = intentsClient.updateIntent(intent, languageCode, updateMask);
+   * }
+   * 
+ * + * @param intent Required. The intent to update. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @param languageCode Optional. The language of training phrases, parameters and rich messages + * defined in `intent`. If not specified, the agent's default language is used. [More than a + * dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note: + * languages must be enabled in the agent, before they can be used. + * @param updateMask Optional. The mask to control which fields get updated. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent updateIntent(Intent intent, String languageCode, FieldMask updateMask) { + + UpdateIntentRequest request = + UpdateIntentRequest.newBuilder() + .setIntent(intent) + .setLanguageCode(languageCode) + .setUpdateMask(updateMask) + .build(); + return updateIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   Intent intent = Intent.newBuilder().build();
+   *   String languageCode = "";
+   *   UpdateIntentRequest request = UpdateIntentRequest.newBuilder()
+   *     .setIntent(intent)
+   *     .setLanguageCode(languageCode)
+   *     .build();
+   *   Intent response = intentsClient.updateIntent(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Intent updateIntent(UpdateIntentRequest request) { + return updateIntentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   Intent intent = Intent.newBuilder().build();
+   *   String languageCode = "";
+   *   UpdateIntentRequest request = UpdateIntentRequest.newBuilder()
+   *     .setIntent(intent)
+   *     .setLanguageCode(languageCode)
+   *     .build();
+   *   ApiFuture<Intent> future = intentsClient.updateIntentCallable().futureCall(request);
+   *   // Do something
+   *   Intent response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable updateIntentCallable() { + return stub.updateIntentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   intentsClient.deleteIntent(name);
+   * }
+   * 
+ * + * @param name Required. The name of the intent to delete. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteIntent(IntentName name) { + + DeleteIntentRequest request = + DeleteIntentRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   intentsClient.deleteIntent(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the intent to delete. Format: `projects/<Project + * ID>/agent/intents/<Intent ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteIntent(String name) { + + DeleteIntentRequest request = DeleteIntentRequest.newBuilder().setName(name).build(); + deleteIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   DeleteIntentRequest request = DeleteIntentRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   intentsClient.deleteIntent(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final void deleteIntent(DeleteIntentRequest request) { + deleteIntentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified intent. + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+   *   DeleteIntentRequest request = DeleteIntentRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = intentsClient.deleteIntentCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteIntentCallable() { + return stub.deleteIntentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates/Creates multiple intents in the specified agent. + * + *

Operation <response: + * [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2.BatchUpdateIntentsResponse]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   String languageCode = "";
+   *   BatchUpdateIntentsRequest request = BatchUpdateIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setLanguageCode(languageCode)
+   *     .build();
+   *   BatchUpdateIntentsResponse response = intentsClient.batchUpdateIntentsAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchUpdateIntentsAsync( + BatchUpdateIntentsRequest request) { + return batchUpdateIntentsOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates/Creates multiple intents in the specified agent. + * + *

Operation <response: + * [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2.BatchUpdateIntentsResponse]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   String languageCode = "";
+   *   BatchUpdateIntentsRequest request = BatchUpdateIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setLanguageCode(languageCode)
+   *     .build();
+   *   OperationFuture<Operation> future = intentsClient.batchUpdateIntentsOperationCallable().futureCall(request);
+   *   // Do something
+   *   BatchUpdateIntentsResponse response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + batchUpdateIntentsOperationCallable() { + return stub.batchUpdateIntentsOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates/Creates multiple intents in the specified agent. + * + *

Operation <response: + * [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2.BatchUpdateIntentsResponse]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   String languageCode = "";
+   *   BatchUpdateIntentsRequest request = BatchUpdateIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setLanguageCode(languageCode)
+   *     .build();
+   *   ApiFuture<Operation> future = intentsClient.batchUpdateIntentsCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable batchUpdateIntentsCallable() { + return stub.batchUpdateIntentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes intents in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<Intent> intents = new ArrayList<>();
+   *   Empty response = intentsClient.batchDeleteIntentsAsync(parent, intents).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the agent to delete all entities types for. Format: + * `projects/<Project ID>/agent`. + * @param intents Required. The collection of intents to delete. Only intent `name` must be filled + * in. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteIntentsAsync( + ProjectAgentName parent, List intents) { + + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .addAllIntents(intents) + .build(); + return batchDeleteIntentsAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes intents in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<Intent> intents = new ArrayList<>();
+   *   Empty response = intentsClient.batchDeleteIntentsAsync(parent.toString(), intents).get();
+   * }
+   * 
+ * + * @param parent Required. The name of the agent to delete all entities types for. Format: + * `projects/<Project ID>/agent`. + * @param intents Required. The collection of intents to delete. Only intent `name` must be filled + * in. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteIntentsAsync( + String parent, List intents) { + + BatchDeleteIntentsRequest request = + BatchDeleteIntentsRequest.newBuilder().setParent(parent).addAllIntents(intents).build(); + return batchDeleteIntentsAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes intents in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<Intent> intents = new ArrayList<>();
+   *   BatchDeleteIntentsRequest request = BatchDeleteIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllIntents(intents)
+   *     .build();
+   *   Empty response = intentsClient.batchDeleteIntentsAsync(request).get();
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture batchDeleteIntentsAsync( + BatchDeleteIntentsRequest request) { + return batchDeleteIntentsOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes intents in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<Intent> intents = new ArrayList<>();
+   *   BatchDeleteIntentsRequest request = BatchDeleteIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllIntents(intents)
+   *     .build();
+   *   OperationFuture<Operation> future = intentsClient.batchDeleteIntentsOperationCallable().futureCall(request);
+   *   // Do something
+   *   Empty response = future.get();
+   * }
+   * 
+ */ + public final OperationCallable + batchDeleteIntentsOperationCallable() { + return stub.batchDeleteIntentsOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes intents in the specified agent. + * + *

Operation <response: [google.protobuf.Empty][google.protobuf.Empty]> + * + *

Sample code: + * + *


+   * try (IntentsClient intentsClient = IntentsClient.create()) {
+   *   ProjectAgentName parent = ProjectAgentName.of("[PROJECT]");
+   *   List<Intent> intents = new ArrayList<>();
+   *   BatchDeleteIntentsRequest request = BatchDeleteIntentsRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .addAllIntents(intents)
+   *     .build();
+   *   ApiFuture<Operation> future = intentsClient.batchDeleteIntentsCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable batchDeleteIntentsCallable() { + return stub.batchDeleteIntentsCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListIntentsPagedResponse + extends AbstractPagedListResponse< + ListIntentsRequest, ListIntentsResponse, Intent, ListIntentsPage, + ListIntentsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListIntentsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListIntentsPagedResponse apply(ListIntentsPage input) { + return new ListIntentsPagedResponse(input); + } + }); + } + + private ListIntentsPagedResponse(ListIntentsPage page) { + super(page, ListIntentsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListIntentsPage + extends AbstractPage { + + private ListIntentsPage( + PageContext context, + ListIntentsResponse response) { + super(context, response); + } + + private static ListIntentsPage createEmptyPage() { + return new ListIntentsPage(null, null); + } + + @Override + protected ListIntentsPage createPage( + PageContext context, + ListIntentsResponse response) { + return new ListIntentsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListIntentsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListIntentsRequest, ListIntentsResponse, Intent, ListIntentsPage, + ListIntentsFixedSizeCollection> { + + private ListIntentsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListIntentsFixedSizeCollection createEmptyCollection() { + return new ListIntentsFixedSizeCollection(null, 0); + } + + @Override + protected ListIntentsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListIntentsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java new file mode 100644 index 000000000000..5ea509aede22 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/IntentsSettings.java @@ -0,0 +1,270 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.IntentsClient.ListIntentsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.dialogflow.v2.stub.IntentsStubSettings; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link IntentsClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getIntent to 30 seconds: + * + *

+ * 
+ * IntentsSettings.Builder intentsSettingsBuilder =
+ *     IntentsSettings.newBuilder();
+ * intentsSettingsBuilder.getIntentSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * IntentsSettings intentsSettings = intentsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class IntentsSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listIntents. */ + public PagedCallSettings + listIntentsSettings() { + return ((IntentsStubSettings) getStubSettings()).listIntentsSettings(); + } + + /** Returns the object with the settings used for calls to getIntent. */ + public UnaryCallSettings getIntentSettings() { + return ((IntentsStubSettings) getStubSettings()).getIntentSettings(); + } + + /** Returns the object with the settings used for calls to createIntent. */ + public UnaryCallSettings createIntentSettings() { + return ((IntentsStubSettings) getStubSettings()).createIntentSettings(); + } + + /** Returns the object with the settings used for calls to updateIntent. */ + public UnaryCallSettings updateIntentSettings() { + return ((IntentsStubSettings) getStubSettings()).updateIntentSettings(); + } + + /** Returns the object with the settings used for calls to deleteIntent. */ + public UnaryCallSettings deleteIntentSettings() { + return ((IntentsStubSettings) getStubSettings()).deleteIntentSettings(); + } + + /** Returns the object with the settings used for calls to batchUpdateIntents. */ + public UnaryCallSettings batchUpdateIntentsSettings() { + return ((IntentsStubSettings) getStubSettings()).batchUpdateIntentsSettings(); + } + + /** Returns the object with the settings used for calls to batchUpdateIntents. */ + public OperationCallSettings + batchUpdateIntentsOperationSettings() { + return ((IntentsStubSettings) getStubSettings()).batchUpdateIntentsOperationSettings(); + } + + /** Returns the object with the settings used for calls to batchDeleteIntents. */ + public UnaryCallSettings batchDeleteIntentsSettings() { + return ((IntentsStubSettings) getStubSettings()).batchDeleteIntentsSettings(); + } + + /** Returns the object with the settings used for calls to batchDeleteIntents. */ + public OperationCallSettings + batchDeleteIntentsOperationSettings() { + return ((IntentsStubSettings) getStubSettings()).batchDeleteIntentsOperationSettings(); + } + + public static final IntentsSettings create(IntentsStubSettings stub) throws IOException { + return new IntentsSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return IntentsStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return IntentsStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return IntentsStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return IntentsStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return IntentsStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return IntentsStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return IntentsStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected IntentsSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for IntentsSettings. */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(IntentsStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(IntentsStubSettings.newBuilder()); + } + + protected Builder(IntentsSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(IntentsStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public IntentsStubSettings.Builder getStubSettingsBuilder() { + return ((IntentsStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to listIntents. */ + public PagedCallSettings.Builder< + ListIntentsRequest, ListIntentsResponse, ListIntentsPagedResponse> + listIntentsSettings() { + return getStubSettingsBuilder().listIntentsSettings(); + } + + /** Returns the builder for the settings used for calls to getIntent. */ + public UnaryCallSettings.Builder getIntentSettings() { + return getStubSettingsBuilder().getIntentSettings(); + } + + /** Returns the builder for the settings used for calls to createIntent. */ + public UnaryCallSettings.Builder createIntentSettings() { + return getStubSettingsBuilder().createIntentSettings(); + } + + /** Returns the builder for the settings used for calls to updateIntent. */ + public UnaryCallSettings.Builder updateIntentSettings() { + return getStubSettingsBuilder().updateIntentSettings(); + } + + /** Returns the builder for the settings used for calls to deleteIntent. */ + public UnaryCallSettings.Builder deleteIntentSettings() { + return getStubSettingsBuilder().deleteIntentSettings(); + } + + /** Returns the builder for the settings used for calls to batchUpdateIntents. */ + public UnaryCallSettings.Builder + batchUpdateIntentsSettings() { + return getStubSettingsBuilder().batchUpdateIntentsSettings(); + } + + /** Returns the builder for the settings used for calls to batchUpdateIntents. */ + public OperationCallSettings.Builder< + BatchUpdateIntentsRequest, BatchUpdateIntentsResponse, Struct> + batchUpdateIntentsOperationSettings() { + return getStubSettingsBuilder().batchUpdateIntentsOperationSettings(); + } + + /** Returns the builder for the settings used for calls to batchDeleteIntents. */ + public UnaryCallSettings.Builder + batchDeleteIntentsSettings() { + return getStubSettingsBuilder().batchDeleteIntentsSettings(); + } + + /** Returns the builder for the settings used for calls to batchDeleteIntents. */ + public OperationCallSettings.Builder + batchDeleteIntentsOperationSettings() { + return getStubSettingsBuilder().batchDeleteIntentsOperationSettings(); + } + + @Override + public IntentsSettings build() throws IOException { + return new IntentsSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java new file mode 100644 index 000000000000..fa9405ee6f55 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClient.java @@ -0,0 +1,786 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.stub.SessionEntityTypesStub; +import com.google.cloud.dialogflow.v2.stub.SessionEntityTypesStubSettings; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: Entities are extracted from user input and represent parameters that are + * meaningful to your application. For example, a date range, a proper name such as a geographic + * location or landmark, and so on. Entities represent actionable data for your application. + * + *

Session entity types are referred to as **User** entity types and are entities + * that are built for an individual user such as favorites, preferences, playlists, and so on. You + * can redefine a session entity type at the session level. + * + *

For more information about entity types, see the [Dialogflow + * documentation](https://dialogflow.com/docs/entities). + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+ *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+ *   SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the sessionEntityTypesClient object to clean up resources + * such as threads. In the example above, try-with-resources is used, which automatically calls + * close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of SessionEntityTypesSettings to + * create(). For example: + * + *

To customize credentials: + * + *

+ * 
+ * SessionEntityTypesSettings sessionEntityTypesSettings =
+ *     SessionEntityTypesSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * SessionEntityTypesClient sessionEntityTypesClient =
+ *     SessionEntityTypesClient.create(sessionEntityTypesSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * SessionEntityTypesSettings sessionEntityTypesSettings =
+ *     SessionEntityTypesSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * SessionEntityTypesClient sessionEntityTypesClient =
+ *     SessionEntityTypesClient.create(sessionEntityTypesSettings);
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class SessionEntityTypesClient implements BackgroundResource { + private final SessionEntityTypesSettings settings; + private final SessionEntityTypesStub stub; + + /** Constructs an instance of SessionEntityTypesClient with default settings. */ + public static final SessionEntityTypesClient create() throws IOException { + return create(SessionEntityTypesSettings.newBuilder().build()); + } + + /** + * Constructs an instance of SessionEntityTypesClient, using the given settings. The channels are + * created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final SessionEntityTypesClient create(SessionEntityTypesSettings settings) + throws IOException { + return new SessionEntityTypesClient(settings); + } + + /** + * Constructs an instance of SessionEntityTypesClient, using the given stub for making calls. This + * is for advanced usage - prefer to use SessionEntityTypesSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final SessionEntityTypesClient create(SessionEntityTypesStub stub) { + return new SessionEntityTypesClient(stub); + } + + /** + * Constructs an instance of SessionEntityTypesClient, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected SessionEntityTypesClient(SessionEntityTypesSettings settings) throws IOException { + this.settings = settings; + this.stub = ((SessionEntityTypesStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected SessionEntityTypesClient(SessionEntityTypesStub stub) { + this.settings = null; + this.stub = stub; + } + + public final SessionEntityTypesSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SessionEntityTypesStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all session entity types in the specified session. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   for (SessionEntityType element : sessionEntityTypesClient.listSessionEntityTypes(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The session to list all session entity types from. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSessionEntityTypesPagedResponse listSessionEntityTypes(SessionName parent) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listSessionEntityTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all session entity types in the specified session. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   for (SessionEntityType element : sessionEntityTypesClient.listSessionEntityTypes(parent.toString()).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. The session to list all session entity types from. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSessionEntityTypesPagedResponse listSessionEntityTypes(String parent) { + ListSessionEntityTypesRequest request = + ListSessionEntityTypesRequest.newBuilder().setParent(parent).build(); + return listSessionEntityTypes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all session entity types in the specified session. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   ListSessionEntityTypesRequest request = ListSessionEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   for (SessionEntityType element : sessionEntityTypesClient.listSessionEntityTypes(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSessionEntityTypesPagedResponse listSessionEntityTypes( + ListSessionEntityTypesRequest request) { + return listSessionEntityTypesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all session entity types in the specified session. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   ListSessionEntityTypesRequest request = ListSessionEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<ListSessionEntityTypesPagedResponse> future = sessionEntityTypesClient.listSessionEntityTypesPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (SessionEntityType element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listSessionEntityTypesPagedCallable() { + return stub.listSessionEntityTypesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Returns the list of all session entity types in the specified session. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   ListSessionEntityTypesRequest request = ListSessionEntityTypesRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   while (true) {
+   *     ListSessionEntityTypesResponse response = sessionEntityTypesClient.listSessionEntityTypesCallable().call(request);
+   *     for (SessionEntityType element : response.getSessionEntityTypesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable + listSessionEntityTypesCallable() { + return stub.listSessionEntityTypesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name);
+   * }
+   * 
+ * + * @param name Required. The name of the session entity type. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/entityTypes/<Entity Type Display Name>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SessionEntityType getSessionEntityType(SessionEntityTypeName name) { + + GetSessionEntityTypeRequest request = + GetSessionEntityTypeRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getSessionEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the session entity type. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/entityTypes/<Entity Type Display Name>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SessionEntityType getSessionEntityType(String name) { + + GetSessionEntityTypeRequest request = + GetSessionEntityTypeRequest.newBuilder().setName(name).build(); + return getSessionEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   GetSessionEntityTypeRequest request = GetSessionEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final SessionEntityType getSessionEntityType(GetSessionEntityTypeRequest request) { + return getSessionEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Retrieves the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   GetSessionEntityTypeRequest request = GetSessionEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<SessionEntityType> future = sessionEntityTypesClient.getSessionEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   SessionEntityType response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + getSessionEntityTypeCallable() { + return stub.getSessionEntityTypeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build();
+   *   SessionEntityType response = sessionEntityTypesClient.createSessionEntityType(parent, sessionEntityType);
+   * }
+   * 
+ * + * @param parent Required. The session to create a session entity type for. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. + * @param sessionEntityType Required. The session entity type to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SessionEntityType createSessionEntityType( + SessionName parent, SessionEntityType sessionEntityType) { + + CreateSessionEntityTypeRequest request = + CreateSessionEntityTypeRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setSessionEntityType(sessionEntityType) + .build(); + return createSessionEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build();
+   *   SessionEntityType response = sessionEntityTypesClient.createSessionEntityType(parent.toString(), sessionEntityType);
+   * }
+   * 
+ * + * @param parent Required. The session to create a session entity type for. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. + * @param sessionEntityType Required. The session entity type to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SessionEntityType createSessionEntityType( + String parent, SessionEntityType sessionEntityType) { + + CreateSessionEntityTypeRequest request = + CreateSessionEntityTypeRequest.newBuilder() + .setParent(parent) + .setSessionEntityType(sessionEntityType) + .build(); + return createSessionEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build();
+   *   CreateSessionEntityTypeRequest request = CreateSessionEntityTypeRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setSessionEntityType(sessionEntityType)
+   *     .build();
+   *   SessionEntityType response = sessionEntityTypesClient.createSessionEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SessionEntityType createSessionEntityType(CreateSessionEntityTypeRequest request) { + return createSessionEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionName parent = SessionName.of("[PROJECT]", "[SESSION]");
+   *   SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build();
+   *   CreateSessionEntityTypeRequest request = CreateSessionEntityTypeRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setSessionEntityType(sessionEntityType)
+   *     .build();
+   *   ApiFuture<SessionEntityType> future = sessionEntityTypesClient.createSessionEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   SessionEntityType response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + createSessionEntityTypeCallable() { + return stub.createSessionEntityTypeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build();
+   *   SessionEntityType response = sessionEntityTypesClient.updateSessionEntityType(sessionEntityType);
+   * }
+   * 
+ * + * @param sessionEntityType Required. The entity type to update. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/entityTypes/<Entity Type Display Name>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SessionEntityType updateSessionEntityType(SessionEntityType sessionEntityType) { + + UpdateSessionEntityTypeRequest request = + UpdateSessionEntityTypeRequest.newBuilder().setSessionEntityType(sessionEntityType).build(); + return updateSessionEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build();
+   *   UpdateSessionEntityTypeRequest request = UpdateSessionEntityTypeRequest.newBuilder()
+   *     .setSessionEntityType(sessionEntityType)
+   *     .build();
+   *   SessionEntityType response = sessionEntityTypesClient.updateSessionEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SessionEntityType updateSessionEntityType(UpdateSessionEntityTypeRequest request) { + return updateSessionEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build();
+   *   UpdateSessionEntityTypeRequest request = UpdateSessionEntityTypeRequest.newBuilder()
+   *     .setSessionEntityType(sessionEntityType)
+   *     .build();
+   *   ApiFuture<SessionEntityType> future = sessionEntityTypesClient.updateSessionEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   SessionEntityType response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + updateSessionEntityTypeCallable() { + return stub.updateSessionEntityTypeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   sessionEntityTypesClient.deleteSessionEntityType(name);
+   * }
+   * 
+ * + * @param name Required. The name of the entity type to delete. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/entityTypes/<Entity Type Display Name>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteSessionEntityType(SessionEntityTypeName name) { + + DeleteSessionEntityTypeRequest request = + DeleteSessionEntityTypeRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + deleteSessionEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   sessionEntityTypesClient.deleteSessionEntityType(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the entity type to delete. Format: `projects/<Project + * ID>/agent/sessions/<Session ID>/entityTypes/<Entity Type Display Name>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteSessionEntityType(String name) { + + DeleteSessionEntityTypeRequest request = + DeleteSessionEntityTypeRequest.newBuilder().setName(name).build(); + deleteSessionEntityType(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   DeleteSessionEntityTypeRequest request = DeleteSessionEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   sessionEntityTypesClient.deleteSessionEntityType(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + private final void deleteSessionEntityType(DeleteSessionEntityTypeRequest request) { + deleteSessionEntityTypeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes the specified session entity type. + * + *

Sample code: + * + *


+   * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+   *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+   *   DeleteSessionEntityTypeRequest request = DeleteSessionEntityTypeRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = sessionEntityTypesClient.deleteSessionEntityTypeCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + deleteSessionEntityTypeCallable() { + return stub.deleteSessionEntityTypeCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListSessionEntityTypesPagedResponse + extends AbstractPagedListResponse< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType, + ListSessionEntityTypesPage, ListSessionEntityTypesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType> + context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListSessionEntityTypesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListSessionEntityTypesPagedResponse apply(ListSessionEntityTypesPage input) { + return new ListSessionEntityTypesPagedResponse(input); + } + }); + } + + private ListSessionEntityTypesPagedResponse(ListSessionEntityTypesPage page) { + super(page, ListSessionEntityTypesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListSessionEntityTypesPage + extends AbstractPage< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType, + ListSessionEntityTypesPage> { + + private ListSessionEntityTypesPage( + PageContext< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType> + context, + ListSessionEntityTypesResponse response) { + super(context, response); + } + + private static ListSessionEntityTypesPage createEmptyPage() { + return new ListSessionEntityTypesPage(null, null); + } + + @Override + protected ListSessionEntityTypesPage createPage( + PageContext< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType> + context, + ListSessionEntityTypesResponse response) { + return new ListSessionEntityTypesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType> + context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListSessionEntityTypesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType, + ListSessionEntityTypesPage, ListSessionEntityTypesFixedSizeCollection> { + + private ListSessionEntityTypesFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListSessionEntityTypesFixedSizeCollection createEmptyCollection() { + return new ListSessionEntityTypesFixedSizeCollection(null, 0); + } + + @Override + protected ListSessionEntityTypesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListSessionEntityTypesFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java new file mode 100644 index 000000000000..267238c367eb --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionEntityTypesSettings.java @@ -0,0 +1,232 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.dialogflow.v2.stub.SessionEntityTypesStubSettings; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SessionEntityTypesClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getSessionEntityType to 30 seconds: + * + *

+ * 
+ * SessionEntityTypesSettings.Builder sessionEntityTypesSettingsBuilder =
+ *     SessionEntityTypesSettings.newBuilder();
+ * sessionEntityTypesSettingsBuilder.getSessionEntityTypeSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * SessionEntityTypesSettings sessionEntityTypesSettings = sessionEntityTypesSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class SessionEntityTypesSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listSessionEntityTypes. */ + public PagedCallSettings< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse> + listSessionEntityTypesSettings() { + return ((SessionEntityTypesStubSettings) getStubSettings()).listSessionEntityTypesSettings(); + } + + /** Returns the object with the settings used for calls to getSessionEntityType. */ + public UnaryCallSettings + getSessionEntityTypeSettings() { + return ((SessionEntityTypesStubSettings) getStubSettings()).getSessionEntityTypeSettings(); + } + + /** Returns the object with the settings used for calls to createSessionEntityType. */ + public UnaryCallSettings + createSessionEntityTypeSettings() { + return ((SessionEntityTypesStubSettings) getStubSettings()).createSessionEntityTypeSettings(); + } + + /** Returns the object with the settings used for calls to updateSessionEntityType. */ + public UnaryCallSettings + updateSessionEntityTypeSettings() { + return ((SessionEntityTypesStubSettings) getStubSettings()).updateSessionEntityTypeSettings(); + } + + /** Returns the object with the settings used for calls to deleteSessionEntityType. */ + public UnaryCallSettings + deleteSessionEntityTypeSettings() { + return ((SessionEntityTypesStubSettings) getStubSettings()).deleteSessionEntityTypeSettings(); + } + + public static final SessionEntityTypesSettings create(SessionEntityTypesStubSettings stub) + throws IOException { + return new SessionEntityTypesSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return SessionEntityTypesStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return SessionEntityTypesStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return SessionEntityTypesStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return SessionEntityTypesStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return SessionEntityTypesStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return SessionEntityTypesStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SessionEntityTypesStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SessionEntityTypesSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for SessionEntityTypesSettings. */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(SessionEntityTypesStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(SessionEntityTypesStubSettings.newBuilder()); + } + + protected Builder(SessionEntityTypesSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(SessionEntityTypesStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public SessionEntityTypesStubSettings.Builder getStubSettingsBuilder() { + return ((SessionEntityTypesStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to listSessionEntityTypes. */ + public PagedCallSettings.Builder< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse> + listSessionEntityTypesSettings() { + return getStubSettingsBuilder().listSessionEntityTypesSettings(); + } + + /** Returns the builder for the settings used for calls to getSessionEntityType. */ + public UnaryCallSettings.Builder + getSessionEntityTypeSettings() { + return getStubSettingsBuilder().getSessionEntityTypeSettings(); + } + + /** Returns the builder for the settings used for calls to createSessionEntityType. */ + public UnaryCallSettings.Builder + createSessionEntityTypeSettings() { + return getStubSettingsBuilder().createSessionEntityTypeSettings(); + } + + /** Returns the builder for the settings used for calls to updateSessionEntityType. */ + public UnaryCallSettings.Builder + updateSessionEntityTypeSettings() { + return getStubSettingsBuilder().updateSessionEntityTypeSettings(); + } + + /** Returns the builder for the settings used for calls to deleteSessionEntityType. */ + public UnaryCallSettings.Builder + deleteSessionEntityTypeSettings() { + return getStubSettingsBuilder().deleteSessionEntityTypeSettings(); + } + + @Override + public SessionEntityTypesSettings build() throws IOException { + return new SessionEntityTypesSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java new file mode 100644 index 000000000000..ae8cb25a9db5 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsClient.java @@ -0,0 +1,348 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.stub.SessionsStub; +import com.google.cloud.dialogflow.v2.stub.SessionsStubSettings; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: A session represents an interaction with a user. You retrieve user input and + * pass it to the [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or + * [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) method to + * determine user intent and respond. + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (SessionsClient sessionsClient = SessionsClient.create()) {
+ *   SessionName session = SessionName.of("[PROJECT]", "[SESSION]");
+ *   QueryInput queryInput = QueryInput.newBuilder().build();
+ *   DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the sessionsClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of SessionsSettings to create(). + * For example: + * + *

To customize credentials: + * + *

+ * 
+ * SessionsSettings sessionsSettings =
+ *     SessionsSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * SessionsClient sessionsClient =
+ *     SessionsClient.create(sessionsSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * SessionsSettings sessionsSettings =
+ *     SessionsSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * SessionsClient sessionsClient =
+ *     SessionsClient.create(sessionsSettings);
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class SessionsClient implements BackgroundResource { + private final SessionsSettings settings; + private final SessionsStub stub; + + /** Constructs an instance of SessionsClient with default settings. */ + public static final SessionsClient create() throws IOException { + return create(SessionsSettings.newBuilder().build()); + } + + /** + * Constructs an instance of SessionsClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final SessionsClient create(SessionsSettings settings) throws IOException { + return new SessionsClient(settings); + } + + /** + * Constructs an instance of SessionsClient, using the given stub for making calls. This is for + * advanced usage - prefer to use SessionsSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final SessionsClient create(SessionsStub stub) { + return new SessionsClient(stub); + } + + /** + * Constructs an instance of SessionsClient, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected SessionsClient(SessionsSettings settings) throws IOException { + this.settings = settings; + this.stub = ((SessionsStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected SessionsClient(SessionsStub stub) { + this.settings = null; + this.stub = stub; + } + + public final SessionsSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SessionsStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Processes a natural language query and returns structured, actionable data as a result. This + * method is not idempotent, because it may cause contexts and session entity types to be updated, + * which in turn might affect results of future queries. + * + *

Sample code: + * + *


+   * try (SessionsClient sessionsClient = SessionsClient.create()) {
+   *   SessionName session = SessionName.of("[PROJECT]", "[SESSION]");
+   *   QueryInput queryInput = QueryInput.newBuilder().build();
+   *   DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);
+   * }
+   * 
+ * + * @param session Required. The name of the session this query is sent to. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. It's up to the API caller + * to choose an appropriate session ID. It can be a random number or some type of user + * identifier (preferably hashed). The length of the session ID must not exceed 36 bytes. + * @param queryInput Required. The input specification. It can be set to: + *

1. an audio config which instructs the speech recognizer how to process the speech + * audio, + *

2. a conversational query in the form of text, or + *

3. an event that specifies which intent to trigger. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final DetectIntentResponse detectIntent(SessionName session, QueryInput queryInput) { + + DetectIntentRequest request = + DetectIntentRequest.newBuilder() + .setSession(session == null ? null : session.toString()) + .setQueryInput(queryInput) + .build(); + return detectIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Processes a natural language query and returns structured, actionable data as a result. This + * method is not idempotent, because it may cause contexts and session entity types to be updated, + * which in turn might affect results of future queries. + * + *

Sample code: + * + *


+   * try (SessionsClient sessionsClient = SessionsClient.create()) {
+   *   SessionName session = SessionName.of("[PROJECT]", "[SESSION]");
+   *   QueryInput queryInput = QueryInput.newBuilder().build();
+   *   DetectIntentResponse response = sessionsClient.detectIntent(session.toString(), queryInput);
+   * }
+   * 
+ * + * @param session Required. The name of the session this query is sent to. Format: + * `projects/<Project ID>/agent/sessions/<Session ID>`. It's up to the API caller + * to choose an appropriate session ID. It can be a random number or some type of user + * identifier (preferably hashed). The length of the session ID must not exceed 36 bytes. + * @param queryInput Required. The input specification. It can be set to: + *

1. an audio config which instructs the speech recognizer how to process the speech + * audio, + *

2. a conversational query in the form of text, or + *

3. an event that specifies which intent to trigger. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final DetectIntentResponse detectIntent(String session, QueryInput queryInput) { + + DetectIntentRequest request = + DetectIntentRequest.newBuilder().setSession(session).setQueryInput(queryInput).build(); + return detectIntent(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Processes a natural language query and returns structured, actionable data as a result. This + * method is not idempotent, because it may cause contexts and session entity types to be updated, + * which in turn might affect results of future queries. + * + *

Sample code: + * + *


+   * try (SessionsClient sessionsClient = SessionsClient.create()) {
+   *   SessionName session = SessionName.of("[PROJECT]", "[SESSION]");
+   *   QueryInput queryInput = QueryInput.newBuilder().build();
+   *   DetectIntentRequest request = DetectIntentRequest.newBuilder()
+   *     .setSession(session.toString())
+   *     .setQueryInput(queryInput)
+   *     .build();
+   *   DetectIntentResponse response = sessionsClient.detectIntent(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final DetectIntentResponse detectIntent(DetectIntentRequest request) { + return detectIntentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Processes a natural language query and returns structured, actionable data as a result. This + * method is not idempotent, because it may cause contexts and session entity types to be updated, + * which in turn might affect results of future queries. + * + *

Sample code: + * + *


+   * try (SessionsClient sessionsClient = SessionsClient.create()) {
+   *   SessionName session = SessionName.of("[PROJECT]", "[SESSION]");
+   *   QueryInput queryInput = QueryInput.newBuilder().build();
+   *   DetectIntentRequest request = DetectIntentRequest.newBuilder()
+   *     .setSession(session.toString())
+   *     .setQueryInput(queryInput)
+   *     .build();
+   *   ApiFuture<DetectIntentResponse> future = sessionsClient.detectIntentCallable().futureCall(request);
+   *   // Do something
+   *   DetectIntentResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable detectIntentCallable() { + return stub.detectIntentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Processes a natural language query in audio format in a streaming fashion and returns + * structured, actionable data as a result. This method is only available via the gRPC API (not + * REST). + * + *

Sample code: + * + *


+   * try (SessionsClient sessionsClient = SessionsClient.create()) {
+   *   ApiStreamObserver<StreamingDetectIntentResponse> responseObserver =
+   *       new ApiStreamObserver<StreamingDetectIntentResponse>() {
+   *         {@literal @}Override
+   *         public void onNext(StreamingDetectIntentResponse response) {
+   *           // Do something when receive a response
+   *         }
+   *
+   *         {@literal @}Override
+   *         public void onError(Throwable t) {
+   *           // Add error-handling
+   *         }
+   *
+   *         {@literal @}Override
+   *         public void onCompleted() {
+   *           // Do something when complete.
+   *         }
+   *       };
+   *   ApiStreamObserver<StreamingRecognizeRequest> requestObserver =
+   *       sessionsClient.streamingDetectIntentCallable().bidiStreamingCall(responseObserver));
+   *
+   *   String session = "";
+   *   QueryInput queryInput = QueryInput.newBuilder().build();
+   *   StreamingDetectIntentRequest request = StreamingDetectIntentRequest.newBuilder()
+   *     .setSession(session)
+   *     .setQueryInput(queryInput)
+   *     .build();
+   *   requestObserver.onNext(request);
+   * }
+   * 
+ */ + public final BidiStreamingCallable + streamingDetectIntentCallable() { + return stub.streamingDetectIntentCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java new file mode 100644 index 000000000000..1f988c35e763 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/SessionsSettings.java @@ -0,0 +1,188 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.dialogflow.v2.stub.SessionsStubSettings; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SessionsClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of detectIntent to 30 seconds: + * + *

+ * 
+ * SessionsSettings.Builder sessionsSettingsBuilder =
+ *     SessionsSettings.newBuilder();
+ * sessionsSettingsBuilder.detectIntentSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * SessionsSettings sessionsSettings = sessionsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class SessionsSettings extends ClientSettings { + /** Returns the object with the settings used for calls to detectIntent. */ + public UnaryCallSettings detectIntentSettings() { + return ((SessionsStubSettings) getStubSettings()).detectIntentSettings(); + } + + /** Returns the object with the settings used for calls to streamingDetectIntent. */ + public StreamingCallSettings + streamingDetectIntentSettings() { + return ((SessionsStubSettings) getStubSettings()).streamingDetectIntentSettings(); + } + + public static final SessionsSettings create(SessionsStubSettings stub) throws IOException { + return new SessionsSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return SessionsStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return SessionsStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return SessionsStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return SessionsStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return SessionsStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return SessionsStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SessionsStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SessionsSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for SessionsSettings. */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(SessionsStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(SessionsStubSettings.newBuilder()); + } + + protected Builder(SessionsSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(SessionsStubSettings.Builder stubSettings) { + super(stubSettings); + } + + public SessionsStubSettings.Builder getStubSettingsBuilder() { + return ((SessionsStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to detectIntent. */ + public UnaryCallSettings.Builder + detectIntentSettings() { + return getStubSettingsBuilder().detectIntentSettings(); + } + + /** Returns the builder for the settings used for calls to streamingDetectIntent. */ + public StreamingCallSettings.Builder< + StreamingDetectIntentRequest, StreamingDetectIntentResponse> + streamingDetectIntentSettings() { + return getStubSettingsBuilder().streamingDetectIntentSettings(); + } + + @Override + public SessionsSettings build() throws IOException { + return new SessionsSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/package-info.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/package-info.java new file mode 100644 index 000000000000..2c7bae85f0a1 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/package-info.java @@ -0,0 +1,211 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A client to Dialogflow API. + * + *

The interfaces provided are listed below, along with usage samples. + * + *

============ AgentsClient ============ + * + *

Service Description: Agents are best described as Natural Language Understanding (NLU) modules + * that transform user requests into actionable data. You can include agents in your app, product, + * or service to determine user intent and respond to the user in a natural way. + * + *

After you create an agent, you can add [Intents][google.cloud.dialogflow.v2.Intents], + * [Contexts][google.cloud.dialogflow.v2.Contexts], [Entity + * Types][google.cloud.dialogflow.v2.EntityTypes], + * [Webhooks][google.cloud.dialogflow.v2.WebhookRequest], and so on to manage the flow of a + * conversation and match user input to predefined intents and actions. + * + *

You can create an agent using both Dialogflow Standard Edition and Dialogflow Enterprise + * Edition. For details, see [Dialogflow Editions](/dialogflow-enterprise/docs/editions). + * + *

You can save your agent for backup or versioning by exporting the agent by using the + * [ExportAgent][google.cloud.dialogflow.v2.Agents.ExportAgent] method. You can import a saved agent + * by using the [ImportAgent][google.cloud.dialogflow.v2.Agents.ImportAgent] method. + * + *

Dialogflow provides several [prebuilt agents](https://dialogflow.com/docs/prebuilt-agents) for + * common conversation scenarios such as determining a date and time, converting currency, and so + * on. + * + *

For more information about agents, see the [Dialogflow + * documentation](https://dialogflow.com/docs/agents). + * + *

Sample for AgentsClient: + * + *

+ * 
+ * try (AgentsClient agentsClient = AgentsClient.create()) {
+ *   ProjectName parent = ProjectName.of("[PROJECT]");
+ *   Agent response = agentsClient.getAgent(parent);
+ * }
+ * 
+ * 
+ * + * ============== ContextsClient ============== + * + *

Service Description: A context represents additional information included with user input or + * with an intent returned by the Dialogflow API. Contexts are helpful for differentiating user + * input which may be vague or have a different meaning depending on additional details from your + * application such as user setting and preferences, previous user input, where the user is in your + * application, geographic location, and so on. + * + *

You can include contexts as input parameters of a + * [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or + * [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) request, or + * as output contexts included in the returned intent. Contexts expire when an intent is matched, + * after the number of `DetectIntent` requests specified by the `lifespan_count` parameter, or after + * 10 minutes if no intents are matched for a `DetectIntent` request. + * + *

For more information about contexts, see the [Dialogflow + * documentation](https://dialogflow.com/docs/contexts). + * + *

Sample for ContextsClient: + * + *

+ * 
+ * try (ContextsClient contextsClient = ContextsClient.create()) {
+ *   ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]");
+ *   Context response = contextsClient.getContext(name);
+ * }
+ * 
+ * 
+ * + * ================= EntityTypesClient ================= + * + *

Service Description: Entities are extracted from user input and represent parameters that are + * meaningful to your application. For example, a date range, a proper name such as a geographic + * location or landmark, and so on. Entities represent actionable data for your application. + * + *

When you define an entity, you can also include synonyms that all map to that entity. For + * example, "soft drink", "soda", "pop", and so on. + * + *

There are three types of entities: + * + *

* **System** - entities that are defined by the Dialogflow API for common + * data types such as date, time, currency, and so on. A system entity is represented by the + * `EntityType` type. + * + *

* **Developer** - entities that are defined by you that represent + * actionable data that is meaningful to your application. For example, you could define a + * `pizza.sauce` entity for red or white pizza sauce, a `pizza.cheese` entity for the different + * types of cheese on a pizza, a `pizza.topping` entity for different toppings, and so on. A + * developer entity is represented by the `EntityType` type. + * + *

* **User** - entities that are built for an individual user such as + * favorites, preferences, playlists, and so on. A user entity is represented by the + * [SessionEntityType][google.cloud.dialogflow.v2.SessionEntityType] type. + * + *

For more information about entity types, see the [Dialogflow + * documentation](https://dialogflow.com/docs/entities). + * + *

Sample for EntityTypesClient: + * + *

+ * 
+ * try (EntityTypesClient entityTypesClient = EntityTypesClient.create()) {
+ *   EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]");
+ *   EntityType response = entityTypesClient.getEntityType(name);
+ * }
+ * 
+ * 
+ * + * ============= IntentsClient ============= + * + *

Service Description: An intent represents a mapping between input from a user and an action to + * be taken by your application. When you pass user input to the + * [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or + * [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) method, the + * Dialogflow API analyzes the input and searches for a matching intent. If no match is found, the + * Dialogflow API returns a fallback intent (`is_fallback` = true). + * + *

You can provide additional information for the Dialogflow API to use to match user input to an + * intent by adding the following to your intent. + * + *

* **Contexts** - provide additional context for intent analysis. For + * example, if an intent is related to an object in your application that plays music, you can + * provide a context to determine when to match the intent if the user input is “turn it off”. You + * can include a context that matches the intent when there is previous user input of "play music", + * and not when there is previous user input of "turn on the light". + * + *

* **Events** - allow for matching an intent by using an event name instead + * of user input. Your application can provide an event name and related parameters to the + * Dialogflow API to match an intent. For example, when your application starts, you can send a + * welcome event with a user name parameter to the Dialogflow API to match an intent with a + * personalized welcome message for the user. + * + *

* **Training phrases** - provide examples of user input to train the + * Dialogflow API agent to better match intents. + * + *

For more information about intents, see the [Dialogflow + * documentation](https://dialogflow.com/docs/intents). + * + *

Sample for IntentsClient: + * + *

+ * 
+ * try (IntentsClient intentsClient = IntentsClient.create()) {
+ *   IntentName name = IntentName.of("[PROJECT]", "[INTENT]");
+ *   Intent response = intentsClient.getIntent(name);
+ * }
+ * 
+ * 
+ * + * ======================== SessionEntityTypesClient ======================== + * + *

Service Description: Entities are extracted from user input and represent parameters that are + * meaningful to your application. For example, a date range, a proper name such as a geographic + * location or landmark, and so on. Entities represent actionable data for your application. + * + *

Session entity types are referred to as **User** entity types and are entities + * that are built for an individual user such as favorites, preferences, playlists, and so on. You + * can redefine a session entity type at the session level. + * + *

For more information about entity types, see the [Dialogflow + * documentation](https://dialogflow.com/docs/entities). + * + *

Sample for SessionEntityTypesClient: + * + *

+ * 
+ * try (SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.create()) {
+ *   SessionEntityTypeName name = SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
+ *   SessionEntityType response = sessionEntityTypesClient.getSessionEntityType(name);
+ * }
+ * 
+ * 
+ * + * ============== SessionsClient ============== + * + *

Service Description: A session represents an interaction with a user. You retrieve user input + * and pass it to the [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or + * [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) method to + * determine user intent and respond. + * + *

Sample for SessionsClient: + * + *

+ * 
+ * try (SessionsClient sessionsClient = SessionsClient.create()) {
+ *   SessionName session = SessionName.of("[PROJECT]", "[SESSION]");
+ *   QueryInput queryInput = QueryInput.newBuilder().build();
+ *   DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);
+ * }
+ * 
+ * 
+ */ +package com.google.cloud.dialogflow.v2; diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java new file mode 100644 index 000000000000..a15ae1099155 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStub.java @@ -0,0 +1,100 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.ExportAgentRequest; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.GetAgentRequest; +import com.google.cloud.dialogflow.v2.ImportAgentRequest; +import com.google.cloud.dialogflow.v2.RestoreAgentRequest; +import com.google.cloud.dialogflow.v2.SearchAgentsRequest; +import com.google.cloud.dialogflow.v2.SearchAgentsResponse; +import com.google.cloud.dialogflow.v2.TrainAgentRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class AgentsStub implements BackgroundResource { + + public OperationsStub getOperationsStub() { + throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + } + + public UnaryCallable getAgentCallable() { + throw new UnsupportedOperationException("Not implemented: getAgentCallable()"); + } + + public UnaryCallable searchAgentsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: searchAgentsPagedCallable()"); + } + + public UnaryCallable searchAgentsCallable() { + throw new UnsupportedOperationException("Not implemented: searchAgentsCallable()"); + } + + public OperationCallable trainAgentOperationCallable() { + throw new UnsupportedOperationException("Not implemented: trainAgentOperationCallable()"); + } + + public UnaryCallable trainAgentCallable() { + throw new UnsupportedOperationException("Not implemented: trainAgentCallable()"); + } + + public OperationCallable + exportAgentOperationCallable() { + throw new UnsupportedOperationException("Not implemented: exportAgentOperationCallable()"); + } + + public UnaryCallable exportAgentCallable() { + throw new UnsupportedOperationException("Not implemented: exportAgentCallable()"); + } + + public OperationCallable importAgentOperationCallable() { + throw new UnsupportedOperationException("Not implemented: importAgentOperationCallable()"); + } + + public UnaryCallable importAgentCallable() { + throw new UnsupportedOperationException("Not implemented: importAgentCallable()"); + } + + public OperationCallable restoreAgentOperationCallable() { + throw new UnsupportedOperationException("Not implemented: restoreAgentOperationCallable()"); + } + + public UnaryCallable restoreAgentCallable() { + throw new UnsupportedOperationException("Not implemented: restoreAgentCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java new file mode 100644 index 000000000000..e103beaa71d9 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java @@ -0,0 +1,626 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.ExportAgentRequest; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.GetAgentRequest; +import com.google.cloud.dialogflow.v2.ImportAgentRequest; +import com.google.cloud.dialogflow.v2.RestoreAgentRequest; +import com.google.cloud.dialogflow.v2.SearchAgentsRequest; +import com.google.cloud.dialogflow.v2.SearchAgentsResponse; +import com.google.cloud.dialogflow.v2.TrainAgentRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link AgentsStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getAgent to 30 seconds: + * + *

+ * 
+ * AgentsStubSettings.Builder agentsSettingsBuilder =
+ *     AgentsStubSettings.newBuilder();
+ * agentsSettingsBuilder.getAgentSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * AgentsStubSettings agentsSettings = agentsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class AgentsStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final UnaryCallSettings getAgentSettings; + private final PagedCallSettings< + SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse> + searchAgentsSettings; + private final UnaryCallSettings trainAgentSettings; + private final OperationCallSettings trainAgentOperationSettings; + private final UnaryCallSettings exportAgentSettings; + private final OperationCallSettings + exportAgentOperationSettings; + private final UnaryCallSettings importAgentSettings; + private final OperationCallSettings + importAgentOperationSettings; + private final UnaryCallSettings restoreAgentSettings; + private final OperationCallSettings + restoreAgentOperationSettings; + + /** Returns the object with the settings used for calls to getAgent. */ + public UnaryCallSettings getAgentSettings() { + return getAgentSettings; + } + + /** Returns the object with the settings used for calls to searchAgents. */ + public PagedCallSettings + searchAgentsSettings() { + return searchAgentsSettings; + } + + /** Returns the object with the settings used for calls to trainAgent. */ + public UnaryCallSettings trainAgentSettings() { + return trainAgentSettings; + } + + /** Returns the object with the settings used for calls to trainAgent. */ + public OperationCallSettings trainAgentOperationSettings() { + return trainAgentOperationSettings; + } + + /** Returns the object with the settings used for calls to exportAgent. */ + public UnaryCallSettings exportAgentSettings() { + return exportAgentSettings; + } + + /** Returns the object with the settings used for calls to exportAgent. */ + public OperationCallSettings + exportAgentOperationSettings() { + return exportAgentOperationSettings; + } + + /** Returns the object with the settings used for calls to importAgent. */ + public UnaryCallSettings importAgentSettings() { + return importAgentSettings; + } + + /** Returns the object with the settings used for calls to importAgent. */ + public OperationCallSettings importAgentOperationSettings() { + return importAgentOperationSettings; + } + + /** Returns the object with the settings used for calls to restoreAgent. */ + public UnaryCallSettings restoreAgentSettings() { + return restoreAgentSettings; + } + + /** Returns the object with the settings used for calls to restoreAgent. */ + public OperationCallSettings restoreAgentOperationSettings() { + return restoreAgentOperationSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public AgentsStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcAgentsStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "dialogflow.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AgentsStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected AgentsStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + getAgentSettings = settingsBuilder.getAgentSettings().build(); + searchAgentsSettings = settingsBuilder.searchAgentsSettings().build(); + trainAgentSettings = settingsBuilder.trainAgentSettings().build(); + trainAgentOperationSettings = settingsBuilder.trainAgentOperationSettings().build(); + exportAgentSettings = settingsBuilder.exportAgentSettings().build(); + exportAgentOperationSettings = settingsBuilder.exportAgentOperationSettings().build(); + importAgentSettings = settingsBuilder.importAgentSettings().build(); + importAgentOperationSettings = settingsBuilder.importAgentOperationSettings().build(); + restoreAgentSettings = settingsBuilder.restoreAgentSettings().build(); + restoreAgentOperationSettings = settingsBuilder.restoreAgentOperationSettings().build(); + } + + private static final PagedListDescriptor + SEARCH_AGENTS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public SearchAgentsRequest injectToken(SearchAgentsRequest payload, String token) { + return SearchAgentsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public SearchAgentsRequest injectPageSize(SearchAgentsRequest payload, int pageSize) { + return SearchAgentsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(SearchAgentsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(SearchAgentsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(SearchAgentsResponse payload) { + return payload.getAgentsList(); + } + }; + + private static final PagedListResponseFactory< + SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse> + SEARCH_AGENTS_PAGE_STR_FACT = + new PagedListResponseFactory< + SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + SearchAgentsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, SEARCH_AGENTS_PAGE_STR_DESC, request, context); + return SearchAgentsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Builder for AgentsStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final UnaryCallSettings.Builder getAgentSettings; + private final PagedCallSettings.Builder< + SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse> + searchAgentsSettings; + private final UnaryCallSettings.Builder trainAgentSettings; + private final OperationCallSettings.Builder + trainAgentOperationSettings; + private final UnaryCallSettings.Builder exportAgentSettings; + private final OperationCallSettings.Builder + exportAgentOperationSettings; + private final UnaryCallSettings.Builder importAgentSettings; + private final OperationCallSettings.Builder + importAgentOperationSettings; + private final UnaryCallSettings.Builder restoreAgentSettings; + private final OperationCallSettings.Builder + restoreAgentOperationSettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + getAgentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + searchAgentsSettings = PagedCallSettings.newBuilder(SEARCH_AGENTS_PAGE_STR_FACT); + + trainAgentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + trainAgentOperationSettings = OperationCallSettings.newBuilder(); + + exportAgentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + exportAgentOperationSettings = OperationCallSettings.newBuilder(); + + importAgentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + importAgentOperationSettings = OperationCallSettings.newBuilder(); + + restoreAgentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + restoreAgentOperationSettings = OperationCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + getAgentSettings, + searchAgentsSettings, + trainAgentSettings, + exportAgentSettings, + importAgentSettings, + restoreAgentSettings); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder + .getAgentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .searchAgentsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .trainAgentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .exportAgentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .importAgentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .restoreAgentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder + .trainAgentOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .exportAgentOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(ExportAgentResponse.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .importAgentOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .restoreAgentOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + return builder; + } + + protected Builder(AgentsStubSettings settings) { + super(settings); + + getAgentSettings = settings.getAgentSettings.toBuilder(); + searchAgentsSettings = settings.searchAgentsSettings.toBuilder(); + trainAgentSettings = settings.trainAgentSettings.toBuilder(); + trainAgentOperationSettings = settings.trainAgentOperationSettings.toBuilder(); + exportAgentSettings = settings.exportAgentSettings.toBuilder(); + exportAgentOperationSettings = settings.exportAgentOperationSettings.toBuilder(); + importAgentSettings = settings.importAgentSettings.toBuilder(); + importAgentOperationSettings = settings.importAgentOperationSettings.toBuilder(); + restoreAgentSettings = settings.restoreAgentSettings.toBuilder(); + restoreAgentOperationSettings = settings.restoreAgentOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + getAgentSettings, + searchAgentsSettings, + trainAgentSettings, + exportAgentSettings, + importAgentSettings, + restoreAgentSettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to getAgent. */ + public UnaryCallSettings.Builder getAgentSettings() { + return getAgentSettings; + } + + /** Returns the builder for the settings used for calls to searchAgents. */ + public PagedCallSettings.Builder< + SearchAgentsRequest, SearchAgentsResponse, SearchAgentsPagedResponse> + searchAgentsSettings() { + return searchAgentsSettings; + } + + /** Returns the builder for the settings used for calls to trainAgent. */ + public UnaryCallSettings.Builder trainAgentSettings() { + return trainAgentSettings; + } + + /** Returns the builder for the settings used for calls to trainAgent. */ + public OperationCallSettings.Builder + trainAgentOperationSettings() { + return trainAgentOperationSettings; + } + + /** Returns the builder for the settings used for calls to exportAgent. */ + public UnaryCallSettings.Builder exportAgentSettings() { + return exportAgentSettings; + } + + /** Returns the builder for the settings used for calls to exportAgent. */ + public OperationCallSettings.Builder + exportAgentOperationSettings() { + return exportAgentOperationSettings; + } + + /** Returns the builder for the settings used for calls to importAgent. */ + public UnaryCallSettings.Builder importAgentSettings() { + return importAgentSettings; + } + + /** Returns the builder for the settings used for calls to importAgent. */ + public OperationCallSettings.Builder + importAgentOperationSettings() { + return importAgentOperationSettings; + } + + /** Returns the builder for the settings used for calls to restoreAgent. */ + public UnaryCallSettings.Builder restoreAgentSettings() { + return restoreAgentSettings; + } + + /** Returns the builder for the settings used for calls to restoreAgent. */ + public OperationCallSettings.Builder + restoreAgentOperationSettings() { + return restoreAgentOperationSettings; + } + + @Override + public AgentsStubSettings build() throws IOException { + return new AgentsStubSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStub.java new file mode 100644 index 000000000000..088cd4157537 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStub.java @@ -0,0 +1,74 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.CreateContextRequest; +import com.google.cloud.dialogflow.v2.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2.DeleteContextRequest; +import com.google.cloud.dialogflow.v2.GetContextRequest; +import com.google.cloud.dialogflow.v2.ListContextsRequest; +import com.google.cloud.dialogflow.v2.ListContextsResponse; +import com.google.cloud.dialogflow.v2.UpdateContextRequest; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class ContextsStub implements BackgroundResource { + + public UnaryCallable listContextsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listContextsPagedCallable()"); + } + + public UnaryCallable listContextsCallable() { + throw new UnsupportedOperationException("Not implemented: listContextsCallable()"); + } + + public UnaryCallable getContextCallable() { + throw new UnsupportedOperationException("Not implemented: getContextCallable()"); + } + + public UnaryCallable createContextCallable() { + throw new UnsupportedOperationException("Not implemented: createContextCallable()"); + } + + public UnaryCallable updateContextCallable() { + throw new UnsupportedOperationException("Not implemented: updateContextCallable()"); + } + + public UnaryCallable deleteContextCallable() { + throw new UnsupportedOperationException("Not implemented: deleteContextCallable()"); + } + + public UnaryCallable deleteAllContextsCallable() { + throw new UnsupportedOperationException("Not implemented: deleteAllContextsCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java new file mode 100644 index 000000000000..101baec7a2b1 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java @@ -0,0 +1,455 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.CreateContextRequest; +import com.google.cloud.dialogflow.v2.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2.DeleteContextRequest; +import com.google.cloud.dialogflow.v2.GetContextRequest; +import com.google.cloud.dialogflow.v2.ListContextsRequest; +import com.google.cloud.dialogflow.v2.ListContextsResponse; +import com.google.cloud.dialogflow.v2.UpdateContextRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link ContextsStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getContext to 30 seconds: + * + *

+ * 
+ * ContextsStubSettings.Builder contextsSettingsBuilder =
+ *     ContextsStubSettings.newBuilder();
+ * contextsSettingsBuilder.getContextSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * ContextsStubSettings contextsSettings = contextsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class ContextsStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final PagedCallSettings< + ListContextsRequest, ListContextsResponse, ListContextsPagedResponse> + listContextsSettings; + private final UnaryCallSettings getContextSettings; + private final UnaryCallSettings createContextSettings; + private final UnaryCallSettings updateContextSettings; + private final UnaryCallSettings deleteContextSettings; + private final UnaryCallSettings deleteAllContextsSettings; + + /** Returns the object with the settings used for calls to listContexts. */ + public PagedCallSettings + listContextsSettings() { + return listContextsSettings; + } + + /** Returns the object with the settings used for calls to getContext. */ + public UnaryCallSettings getContextSettings() { + return getContextSettings; + } + + /** Returns the object with the settings used for calls to createContext. */ + public UnaryCallSettings createContextSettings() { + return createContextSettings; + } + + /** Returns the object with the settings used for calls to updateContext. */ + public UnaryCallSettings updateContextSettings() { + return updateContextSettings; + } + + /** Returns the object with the settings used for calls to deleteContext. */ + public UnaryCallSettings deleteContextSettings() { + return deleteContextSettings; + } + + /** Returns the object with the settings used for calls to deleteAllContexts. */ + public UnaryCallSettings deleteAllContextsSettings() { + return deleteAllContextsSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public ContextsStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcContextsStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "dialogflow.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(ContextsStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected ContextsStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listContextsSettings = settingsBuilder.listContextsSettings().build(); + getContextSettings = settingsBuilder.getContextSettings().build(); + createContextSettings = settingsBuilder.createContextSettings().build(); + updateContextSettings = settingsBuilder.updateContextSettings().build(); + deleteContextSettings = settingsBuilder.deleteContextSettings().build(); + deleteAllContextsSettings = settingsBuilder.deleteAllContextsSettings().build(); + } + + private static final PagedListDescriptor + LIST_CONTEXTS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListContextsRequest injectToken(ListContextsRequest payload, String token) { + return ListContextsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListContextsRequest injectPageSize(ListContextsRequest payload, int pageSize) { + return ListContextsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListContextsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListContextsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListContextsResponse payload) { + return payload.getContextsList(); + } + }; + + private static final PagedListResponseFactory< + ListContextsRequest, ListContextsResponse, ListContextsPagedResponse> + LIST_CONTEXTS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListContextsRequest, ListContextsResponse, ListContextsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListContextsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_CONTEXTS_PAGE_STR_DESC, request, context); + return ListContextsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Builder for ContextsStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final PagedCallSettings.Builder< + ListContextsRequest, ListContextsResponse, ListContextsPagedResponse> + listContextsSettings; + private final UnaryCallSettings.Builder getContextSettings; + private final UnaryCallSettings.Builder createContextSettings; + private final UnaryCallSettings.Builder updateContextSettings; + private final UnaryCallSettings.Builder deleteContextSettings; + private final UnaryCallSettings.Builder + deleteAllContextsSettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listContextsSettings = PagedCallSettings.newBuilder(LIST_CONTEXTS_PAGE_STR_FACT); + + getContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + createContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + updateContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + deleteContextSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + deleteAllContextsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listContextsSettings, + getContextSettings, + createContextSettings, + updateContextSettings, + deleteContextSettings, + deleteAllContextsSettings); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder + .listContextsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .getContextSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .createContextSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .updateContextSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .deleteContextSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .deleteAllContextsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + return builder; + } + + protected Builder(ContextsStubSettings settings) { + super(settings); + + listContextsSettings = settings.listContextsSettings.toBuilder(); + getContextSettings = settings.getContextSettings.toBuilder(); + createContextSettings = settings.createContextSettings.toBuilder(); + updateContextSettings = settings.updateContextSettings.toBuilder(); + deleteContextSettings = settings.deleteContextSettings.toBuilder(); + deleteAllContextsSettings = settings.deleteAllContextsSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listContextsSettings, + getContextSettings, + createContextSettings, + updateContextSettings, + deleteContextSettings, + deleteAllContextsSettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to listContexts. */ + public PagedCallSettings.Builder< + ListContextsRequest, ListContextsResponse, ListContextsPagedResponse> + listContextsSettings() { + return listContextsSettings; + } + + /** Returns the builder for the settings used for calls to getContext. */ + public UnaryCallSettings.Builder getContextSettings() { + return getContextSettings; + } + + /** Returns the builder for the settings used for calls to createContext. */ + public UnaryCallSettings.Builder createContextSettings() { + return createContextSettings; + } + + /** Returns the builder for the settings used for calls to updateContext. */ + public UnaryCallSettings.Builder updateContextSettings() { + return updateContextSettings; + } + + /** Returns the builder for the settings used for calls to deleteContext. */ + public UnaryCallSettings.Builder deleteContextSettings() { + return deleteContextSettings; + } + + /** Returns the builder for the settings used for calls to deleteAllContexts. */ + public UnaryCallSettings.Builder deleteAllContextsSettings() { + return deleteAllContextsSettings; + } + + @Override + public ContextsStubSettings build() throws IOException { + return new ContextsStubSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java new file mode 100644 index 000000000000..1602a60f57af --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStub.java @@ -0,0 +1,134 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.EntityTypesClient.ListEntityTypesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.GetEntityTypeRequest; +import com.google.cloud.dialogflow.v2.ListEntityTypesRequest; +import com.google.cloud.dialogflow.v2.ListEntityTypesResponse; +import com.google.cloud.dialogflow.v2.UpdateEntityTypeRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class EntityTypesStub implements BackgroundResource { + + public OperationsStub getOperationsStub() { + throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + } + + public UnaryCallable + listEntityTypesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listEntityTypesPagedCallable()"); + } + + public UnaryCallable listEntityTypesCallable() { + throw new UnsupportedOperationException("Not implemented: listEntityTypesCallable()"); + } + + public UnaryCallable getEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: getEntityTypeCallable()"); + } + + public UnaryCallable createEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: createEntityTypeCallable()"); + } + + public UnaryCallable updateEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: updateEntityTypeCallable()"); + } + + public UnaryCallable deleteEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: deleteEntityTypeCallable()"); + } + + public OperationCallable + batchUpdateEntityTypesOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: batchUpdateEntityTypesOperationCallable()"); + } + + public UnaryCallable batchUpdateEntityTypesCallable() { + throw new UnsupportedOperationException("Not implemented: batchUpdateEntityTypesCallable()"); + } + + public OperationCallable + batchDeleteEntityTypesOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: batchDeleteEntityTypesOperationCallable()"); + } + + public UnaryCallable batchDeleteEntityTypesCallable() { + throw new UnsupportedOperationException("Not implemented: batchDeleteEntityTypesCallable()"); + } + + public OperationCallable + batchCreateEntitiesOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: batchCreateEntitiesOperationCallable()"); + } + + public UnaryCallable batchCreateEntitiesCallable() { + throw new UnsupportedOperationException("Not implemented: batchCreateEntitiesCallable()"); + } + + public OperationCallable + batchUpdateEntitiesOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: batchUpdateEntitiesOperationCallable()"); + } + + public UnaryCallable batchUpdateEntitiesCallable() { + throw new UnsupportedOperationException("Not implemented: batchUpdateEntitiesCallable()"); + } + + public OperationCallable + batchDeleteEntitiesOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: batchDeleteEntitiesOperationCallable()"); + } + + public UnaryCallable batchDeleteEntitiesCallable() { + throw new UnsupportedOperationException("Not implemented: batchDeleteEntitiesCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java new file mode 100644 index 000000000000..e391e86a78e4 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/EntityTypesStubSettings.java @@ -0,0 +1,814 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.EntityTypesClient.ListEntityTypesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.GetEntityTypeRequest; +import com.google.cloud.dialogflow.v2.ListEntityTypesRequest; +import com.google.cloud.dialogflow.v2.ListEntityTypesResponse; +import com.google.cloud.dialogflow.v2.UpdateEntityTypeRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link EntityTypesStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getEntityType to 30 seconds: + * + *

+ * 
+ * EntityTypesStubSettings.Builder entityTypesSettingsBuilder =
+ *     EntityTypesStubSettings.newBuilder();
+ * entityTypesSettingsBuilder.getEntityTypeSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * EntityTypesStubSettings entityTypesSettings = entityTypesSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class EntityTypesStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final PagedCallSettings< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse> + listEntityTypesSettings; + private final UnaryCallSettings getEntityTypeSettings; + private final UnaryCallSettings createEntityTypeSettings; + private final UnaryCallSettings updateEntityTypeSettings; + private final UnaryCallSettings deleteEntityTypeSettings; + private final UnaryCallSettings + batchUpdateEntityTypesSettings; + private final OperationCallSettings< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationSettings; + private final UnaryCallSettings + batchDeleteEntityTypesSettings; + private final OperationCallSettings + batchDeleteEntityTypesOperationSettings; + private final UnaryCallSettings + batchCreateEntitiesSettings; + private final OperationCallSettings + batchCreateEntitiesOperationSettings; + private final UnaryCallSettings + batchUpdateEntitiesSettings; + private final OperationCallSettings + batchUpdateEntitiesOperationSettings; + private final UnaryCallSettings + batchDeleteEntitiesSettings; + private final OperationCallSettings + batchDeleteEntitiesOperationSettings; + + /** Returns the object with the settings used for calls to listEntityTypes. */ + public PagedCallSettings< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse> + listEntityTypesSettings() { + return listEntityTypesSettings; + } + + /** Returns the object with the settings used for calls to getEntityType. */ + public UnaryCallSettings getEntityTypeSettings() { + return getEntityTypeSettings; + } + + /** Returns the object with the settings used for calls to createEntityType. */ + public UnaryCallSettings createEntityTypeSettings() { + return createEntityTypeSettings; + } + + /** Returns the object with the settings used for calls to updateEntityType. */ + public UnaryCallSettings updateEntityTypeSettings() { + return updateEntityTypeSettings; + } + + /** Returns the object with the settings used for calls to deleteEntityType. */ + public UnaryCallSettings deleteEntityTypeSettings() { + return deleteEntityTypeSettings; + } + + /** Returns the object with the settings used for calls to batchUpdateEntityTypes. */ + public UnaryCallSettings + batchUpdateEntityTypesSettings() { + return batchUpdateEntityTypesSettings; + } + + /** Returns the object with the settings used for calls to batchUpdateEntityTypes. */ + public OperationCallSettings< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationSettings() { + return batchUpdateEntityTypesOperationSettings; + } + + /** Returns the object with the settings used for calls to batchDeleteEntityTypes. */ + public UnaryCallSettings + batchDeleteEntityTypesSettings() { + return batchDeleteEntityTypesSettings; + } + + /** Returns the object with the settings used for calls to batchDeleteEntityTypes. */ + public OperationCallSettings + batchDeleteEntityTypesOperationSettings() { + return batchDeleteEntityTypesOperationSettings; + } + + /** Returns the object with the settings used for calls to batchCreateEntities. */ + public UnaryCallSettings batchCreateEntitiesSettings() { + return batchCreateEntitiesSettings; + } + + /** Returns the object with the settings used for calls to batchCreateEntities. */ + public OperationCallSettings + batchCreateEntitiesOperationSettings() { + return batchCreateEntitiesOperationSettings; + } + + /** Returns the object with the settings used for calls to batchUpdateEntities. */ + public UnaryCallSettings batchUpdateEntitiesSettings() { + return batchUpdateEntitiesSettings; + } + + /** Returns the object with the settings used for calls to batchUpdateEntities. */ + public OperationCallSettings + batchUpdateEntitiesOperationSettings() { + return batchUpdateEntitiesOperationSettings; + } + + /** Returns the object with the settings used for calls to batchDeleteEntities. */ + public UnaryCallSettings batchDeleteEntitiesSettings() { + return batchDeleteEntitiesSettings; + } + + /** Returns the object with the settings used for calls to batchDeleteEntities. */ + public OperationCallSettings + batchDeleteEntitiesOperationSettings() { + return batchDeleteEntitiesOperationSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public EntityTypesStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcEntityTypesStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "dialogflow.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(EntityTypesStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected EntityTypesStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listEntityTypesSettings = settingsBuilder.listEntityTypesSettings().build(); + getEntityTypeSettings = settingsBuilder.getEntityTypeSettings().build(); + createEntityTypeSettings = settingsBuilder.createEntityTypeSettings().build(); + updateEntityTypeSettings = settingsBuilder.updateEntityTypeSettings().build(); + deleteEntityTypeSettings = settingsBuilder.deleteEntityTypeSettings().build(); + batchUpdateEntityTypesSettings = settingsBuilder.batchUpdateEntityTypesSettings().build(); + batchUpdateEntityTypesOperationSettings = + settingsBuilder.batchUpdateEntityTypesOperationSettings().build(); + batchDeleteEntityTypesSettings = settingsBuilder.batchDeleteEntityTypesSettings().build(); + batchDeleteEntityTypesOperationSettings = + settingsBuilder.batchDeleteEntityTypesOperationSettings().build(); + batchCreateEntitiesSettings = settingsBuilder.batchCreateEntitiesSettings().build(); + batchCreateEntitiesOperationSettings = + settingsBuilder.batchCreateEntitiesOperationSettings().build(); + batchUpdateEntitiesSettings = settingsBuilder.batchUpdateEntitiesSettings().build(); + batchUpdateEntitiesOperationSettings = + settingsBuilder.batchUpdateEntitiesOperationSettings().build(); + batchDeleteEntitiesSettings = settingsBuilder.batchDeleteEntitiesSettings().build(); + batchDeleteEntitiesOperationSettings = + settingsBuilder.batchDeleteEntitiesOperationSettings().build(); + } + + private static final PagedListDescriptor< + ListEntityTypesRequest, ListEntityTypesResponse, EntityType> + LIST_ENTITY_TYPES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListEntityTypesRequest injectToken( + ListEntityTypesRequest payload, String token) { + return ListEntityTypesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListEntityTypesRequest injectPageSize( + ListEntityTypesRequest payload, int pageSize) { + return ListEntityTypesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListEntityTypesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListEntityTypesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListEntityTypesResponse payload) { + return payload.getEntityTypesList(); + } + }; + + private static final PagedListResponseFactory< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse> + LIST_ENTITY_TYPES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListEntityTypesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_ENTITY_TYPES_PAGE_STR_DESC, request, context); + return ListEntityTypesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Builder for EntityTypesStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final PagedCallSettings.Builder< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse> + listEntityTypesSettings; + private final UnaryCallSettings.Builder getEntityTypeSettings; + private final UnaryCallSettings.Builder + createEntityTypeSettings; + private final UnaryCallSettings.Builder + updateEntityTypeSettings; + private final UnaryCallSettings.Builder + deleteEntityTypeSettings; + private final UnaryCallSettings.Builder + batchUpdateEntityTypesSettings; + private final OperationCallSettings.Builder< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationSettings; + private final UnaryCallSettings.Builder + batchDeleteEntityTypesSettings; + private final OperationCallSettings.Builder + batchDeleteEntityTypesOperationSettings; + private final UnaryCallSettings.Builder + batchCreateEntitiesSettings; + private final OperationCallSettings.Builder + batchCreateEntitiesOperationSettings; + private final UnaryCallSettings.Builder + batchUpdateEntitiesSettings; + private final OperationCallSettings.Builder + batchUpdateEntitiesOperationSettings; + private final UnaryCallSettings.Builder + batchDeleteEntitiesSettings; + private final OperationCallSettings.Builder + batchDeleteEntitiesOperationSettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listEntityTypesSettings = PagedCallSettings.newBuilder(LIST_ENTITY_TYPES_PAGE_STR_FACT); + + getEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + createEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + updateEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + deleteEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchUpdateEntityTypesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchUpdateEntityTypesOperationSettings = OperationCallSettings.newBuilder(); + + batchDeleteEntityTypesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchDeleteEntityTypesOperationSettings = OperationCallSettings.newBuilder(); + + batchCreateEntitiesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchCreateEntitiesOperationSettings = OperationCallSettings.newBuilder(); + + batchUpdateEntitiesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchUpdateEntitiesOperationSettings = OperationCallSettings.newBuilder(); + + batchDeleteEntitiesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchDeleteEntitiesOperationSettings = OperationCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listEntityTypesSettings, + getEntityTypeSettings, + createEntityTypeSettings, + updateEntityTypeSettings, + deleteEntityTypeSettings, + batchUpdateEntityTypesSettings, + batchDeleteEntityTypesSettings, + batchCreateEntitiesSettings, + batchUpdateEntitiesSettings, + batchDeleteEntitiesSettings); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder + .listEntityTypesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .getEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .createEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .updateEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .deleteEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .batchUpdateEntityTypesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .batchDeleteEntityTypesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .batchCreateEntitiesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .batchUpdateEntitiesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .batchDeleteEntitiesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder + .batchUpdateEntityTypesOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create( + BatchUpdateEntityTypesResponse.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .batchDeleteEntityTypesOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .batchCreateEntitiesOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .batchUpdateEntitiesOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .batchDeleteEntitiesOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + return builder; + } + + protected Builder(EntityTypesStubSettings settings) { + super(settings); + + listEntityTypesSettings = settings.listEntityTypesSettings.toBuilder(); + getEntityTypeSettings = settings.getEntityTypeSettings.toBuilder(); + createEntityTypeSettings = settings.createEntityTypeSettings.toBuilder(); + updateEntityTypeSettings = settings.updateEntityTypeSettings.toBuilder(); + deleteEntityTypeSettings = settings.deleteEntityTypeSettings.toBuilder(); + batchUpdateEntityTypesSettings = settings.batchUpdateEntityTypesSettings.toBuilder(); + batchUpdateEntityTypesOperationSettings = + settings.batchUpdateEntityTypesOperationSettings.toBuilder(); + batchDeleteEntityTypesSettings = settings.batchDeleteEntityTypesSettings.toBuilder(); + batchDeleteEntityTypesOperationSettings = + settings.batchDeleteEntityTypesOperationSettings.toBuilder(); + batchCreateEntitiesSettings = settings.batchCreateEntitiesSettings.toBuilder(); + batchCreateEntitiesOperationSettings = + settings.batchCreateEntitiesOperationSettings.toBuilder(); + batchUpdateEntitiesSettings = settings.batchUpdateEntitiesSettings.toBuilder(); + batchUpdateEntitiesOperationSettings = + settings.batchUpdateEntitiesOperationSettings.toBuilder(); + batchDeleteEntitiesSettings = settings.batchDeleteEntitiesSettings.toBuilder(); + batchDeleteEntitiesOperationSettings = + settings.batchDeleteEntitiesOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listEntityTypesSettings, + getEntityTypeSettings, + createEntityTypeSettings, + updateEntityTypeSettings, + deleteEntityTypeSettings, + batchUpdateEntityTypesSettings, + batchDeleteEntityTypesSettings, + batchCreateEntitiesSettings, + batchUpdateEntitiesSettings, + batchDeleteEntitiesSettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to listEntityTypes. */ + public PagedCallSettings.Builder< + ListEntityTypesRequest, ListEntityTypesResponse, ListEntityTypesPagedResponse> + listEntityTypesSettings() { + return listEntityTypesSettings; + } + + /** Returns the builder for the settings used for calls to getEntityType. */ + public UnaryCallSettings.Builder getEntityTypeSettings() { + return getEntityTypeSettings; + } + + /** Returns the builder for the settings used for calls to createEntityType. */ + public UnaryCallSettings.Builder + createEntityTypeSettings() { + return createEntityTypeSettings; + } + + /** Returns the builder for the settings used for calls to updateEntityType. */ + public UnaryCallSettings.Builder + updateEntityTypeSettings() { + return updateEntityTypeSettings; + } + + /** Returns the builder for the settings used for calls to deleteEntityType. */ + public UnaryCallSettings.Builder deleteEntityTypeSettings() { + return deleteEntityTypeSettings; + } + + /** Returns the builder for the settings used for calls to batchUpdateEntityTypes. */ + public UnaryCallSettings.Builder + batchUpdateEntityTypesSettings() { + return batchUpdateEntityTypesSettings; + } + + /** Returns the builder for the settings used for calls to batchUpdateEntityTypes. */ + public OperationCallSettings.Builder< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationSettings() { + return batchUpdateEntityTypesOperationSettings; + } + + /** Returns the builder for the settings used for calls to batchDeleteEntityTypes. */ + public UnaryCallSettings.Builder + batchDeleteEntityTypesSettings() { + return batchDeleteEntityTypesSettings; + } + + /** Returns the builder for the settings used for calls to batchDeleteEntityTypes. */ + public OperationCallSettings.Builder + batchDeleteEntityTypesOperationSettings() { + return batchDeleteEntityTypesOperationSettings; + } + + /** Returns the builder for the settings used for calls to batchCreateEntities. */ + public UnaryCallSettings.Builder + batchCreateEntitiesSettings() { + return batchCreateEntitiesSettings; + } + + /** Returns the builder for the settings used for calls to batchCreateEntities. */ + public OperationCallSettings.Builder + batchCreateEntitiesOperationSettings() { + return batchCreateEntitiesOperationSettings; + } + + /** Returns the builder for the settings used for calls to batchUpdateEntities. */ + public UnaryCallSettings.Builder + batchUpdateEntitiesSettings() { + return batchUpdateEntitiesSettings; + } + + /** Returns the builder for the settings used for calls to batchUpdateEntities. */ + public OperationCallSettings.Builder + batchUpdateEntitiesOperationSettings() { + return batchUpdateEntitiesOperationSettings; + } + + /** Returns the builder for the settings used for calls to batchDeleteEntities. */ + public UnaryCallSettings.Builder + batchDeleteEntitiesSettings() { + return batchDeleteEntitiesSettings; + } + + /** Returns the builder for the settings used for calls to batchDeleteEntities. */ + public OperationCallSettings.Builder + batchDeleteEntitiesOperationSettings() { + return batchDeleteEntitiesOperationSettings; + } + + @Override + public EntityTypesStubSettings build() throws IOException { + return new EntityTypesStubSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsCallableFactory.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsCallableFactory.java new file mode 100644 index 000000000000..8d3a1806c8a2 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsCallableFactory.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC callable factory implementation for Dialogflow API. + * + *

This class is for advanced usage. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class GrpcAgentsCallableFactory implements GrpcStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, batchingCallSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, operationCallSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsStub.java new file mode 100644 index 000000000000..b5d45cde2bd6 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcAgentsStub.java @@ -0,0 +1,309 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.Agent; +import com.google.cloud.dialogflow.v2.ExportAgentRequest; +import com.google.cloud.dialogflow.v2.ExportAgentResponse; +import com.google.cloud.dialogflow.v2.GetAgentRequest; +import com.google.cloud.dialogflow.v2.ImportAgentRequest; +import com.google.cloud.dialogflow.v2.RestoreAgentRequest; +import com.google.cloud.dialogflow.v2.SearchAgentsRequest; +import com.google.cloud.dialogflow.v2.SearchAgentsResponse; +import com.google.cloud.dialogflow.v2.TrainAgentRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC stub implementation for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class GrpcAgentsStub extends AgentsStub { + + private static final MethodDescriptor getAgentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Agents/GetAgent") + .setRequestMarshaller(ProtoUtils.marshaller(GetAgentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Agent.getDefaultInstance())) + .build(); + private static final MethodDescriptor + searchAgentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Agents/SearchAgents") + .setRequestMarshaller(ProtoUtils.marshaller(SearchAgentsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(SearchAgentsResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor trainAgentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Agents/TrainAgent") + .setRequestMarshaller(ProtoUtils.marshaller(TrainAgentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor exportAgentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Agents/ExportAgent") + .setRequestMarshaller(ProtoUtils.marshaller(ExportAgentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor importAgentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Agents/ImportAgent") + .setRequestMarshaller(ProtoUtils.marshaller(ImportAgentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + restoreAgentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Agents/RestoreAgent") + .setRequestMarshaller(ProtoUtils.marshaller(RestoreAgentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + + private final UnaryCallable getAgentCallable; + private final UnaryCallable searchAgentsCallable; + private final UnaryCallable + searchAgentsPagedCallable; + private final UnaryCallable trainAgentCallable; + private final OperationCallable trainAgentOperationCallable; + private final UnaryCallable exportAgentCallable; + private final OperationCallable + exportAgentOperationCallable; + private final UnaryCallable importAgentCallable; + private final OperationCallable importAgentOperationCallable; + private final UnaryCallable restoreAgentCallable; + private final OperationCallable restoreAgentOperationCallable; + + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcAgentsStub create(AgentsStubSettings settings) throws IOException { + return new GrpcAgentsStub(settings, ClientContext.create(settings)); + } + + public static final GrpcAgentsStub create(ClientContext clientContext) throws IOException { + return new GrpcAgentsStub(AgentsStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcAgentsStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcAgentsStub( + AgentsStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcAgentsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcAgentsStub(AgentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcAgentsCallableFactory()); + } + + /** + * Constructs an instance of GrpcAgentsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcAgentsStub( + AgentsStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings getAgentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getAgentMethodDescriptor) + .build(); + GrpcCallSettings searchAgentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(searchAgentsMethodDescriptor) + .build(); + GrpcCallSettings trainAgentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(trainAgentMethodDescriptor) + .build(); + GrpcCallSettings exportAgentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(exportAgentMethodDescriptor) + .build(); + GrpcCallSettings importAgentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(importAgentMethodDescriptor) + .build(); + GrpcCallSettings restoreAgentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(restoreAgentMethodDescriptor) + .build(); + + this.getAgentCallable = + callableFactory.createUnaryCallable( + getAgentTransportSettings, settings.getAgentSettings(), clientContext); + this.searchAgentsCallable = + callableFactory.createUnaryCallable( + searchAgentsTransportSettings, settings.searchAgentsSettings(), clientContext); + this.searchAgentsPagedCallable = + callableFactory.createPagedCallable( + searchAgentsTransportSettings, settings.searchAgentsSettings(), clientContext); + this.trainAgentCallable = + callableFactory.createUnaryCallable( + trainAgentTransportSettings, settings.trainAgentSettings(), clientContext); + this.trainAgentOperationCallable = + callableFactory.createOperationCallable( + trainAgentTransportSettings, + settings.trainAgentOperationSettings(), + clientContext, + this.operationsStub); + this.exportAgentCallable = + callableFactory.createUnaryCallable( + exportAgentTransportSettings, settings.exportAgentSettings(), clientContext); + this.exportAgentOperationCallable = + callableFactory.createOperationCallable( + exportAgentTransportSettings, + settings.exportAgentOperationSettings(), + clientContext, + this.operationsStub); + this.importAgentCallable = + callableFactory.createUnaryCallable( + importAgentTransportSettings, settings.importAgentSettings(), clientContext); + this.importAgentOperationCallable = + callableFactory.createOperationCallable( + importAgentTransportSettings, + settings.importAgentOperationSettings(), + clientContext, + this.operationsStub); + this.restoreAgentCallable = + callableFactory.createUnaryCallable( + restoreAgentTransportSettings, settings.restoreAgentSettings(), clientContext); + this.restoreAgentOperationCallable = + callableFactory.createOperationCallable( + restoreAgentTransportSettings, + settings.restoreAgentOperationSettings(), + clientContext, + this.operationsStub); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + public UnaryCallable getAgentCallable() { + return getAgentCallable; + } + + public UnaryCallable searchAgentsPagedCallable() { + return searchAgentsPagedCallable; + } + + public UnaryCallable searchAgentsCallable() { + return searchAgentsCallable; + } + + public OperationCallable trainAgentOperationCallable() { + return trainAgentOperationCallable; + } + + public UnaryCallable trainAgentCallable() { + return trainAgentCallable; + } + + public OperationCallable + exportAgentOperationCallable() { + return exportAgentOperationCallable; + } + + public UnaryCallable exportAgentCallable() { + return exportAgentCallable; + } + + public OperationCallable importAgentOperationCallable() { + return importAgentOperationCallable; + } + + public UnaryCallable importAgentCallable() { + return importAgentCallable; + } + + public OperationCallable restoreAgentOperationCallable() { + return restoreAgentOperationCallable; + } + + public UnaryCallable restoreAgentCallable() { + return restoreAgentCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsCallableFactory.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsCallableFactory.java new file mode 100644 index 000000000000..b64bfec4e42c --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsCallableFactory.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC callable factory implementation for Dialogflow API. + * + *

This class is for advanced usage. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class GrpcContextsCallableFactory implements GrpcStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, batchingCallSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, operationCallSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsStub.java new file mode 100644 index 000000000000..e7daf58e0b58 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcContextsStub.java @@ -0,0 +1,259 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.Context; +import com.google.cloud.dialogflow.v2.CreateContextRequest; +import com.google.cloud.dialogflow.v2.DeleteAllContextsRequest; +import com.google.cloud.dialogflow.v2.DeleteContextRequest; +import com.google.cloud.dialogflow.v2.GetContextRequest; +import com.google.cloud.dialogflow.v2.ListContextsRequest; +import com.google.cloud.dialogflow.v2.ListContextsResponse; +import com.google.cloud.dialogflow.v2.UpdateContextRequest; +import com.google.protobuf.Empty; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC stub implementation for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class GrpcContextsStub extends ContextsStub { + + private static final MethodDescriptor + listContextsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/ListContexts") + .setRequestMarshaller(ProtoUtils.marshaller(ListContextsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListContextsResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor getContextMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/GetContext") + .setRequestMarshaller(ProtoUtils.marshaller(GetContextRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Context.getDefaultInstance())) + .build(); + private static final MethodDescriptor + createContextMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/CreateContext") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateContextRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Context.getDefaultInstance())) + .build(); + private static final MethodDescriptor + updateContextMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/UpdateContext") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateContextRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Context.getDefaultInstance())) + .build(); + private static final MethodDescriptor deleteContextMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/DeleteContext") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteContextRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + private static final MethodDescriptor + deleteAllContextsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Contexts/DeleteAllContexts") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteAllContextsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private final BackgroundResource backgroundResources; + + private final UnaryCallable listContextsCallable; + private final UnaryCallable + listContextsPagedCallable; + private final UnaryCallable getContextCallable; + private final UnaryCallable createContextCallable; + private final UnaryCallable updateContextCallable; + private final UnaryCallable deleteContextCallable; + private final UnaryCallable deleteAllContextsCallable; + + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcContextsStub create(ContextsStubSettings settings) throws IOException { + return new GrpcContextsStub(settings, ClientContext.create(settings)); + } + + public static final GrpcContextsStub create(ClientContext clientContext) throws IOException { + return new GrpcContextsStub(ContextsStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcContextsStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcContextsStub( + ContextsStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcContextsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcContextsStub(ContextsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcContextsCallableFactory()); + } + + /** + * Constructs an instance of GrpcContextsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcContextsStub( + ContextsStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + GrpcCallSettings listContextsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listContextsMethodDescriptor) + .build(); + GrpcCallSettings getContextTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getContextMethodDescriptor) + .build(); + GrpcCallSettings createContextTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createContextMethodDescriptor) + .build(); + GrpcCallSettings updateContextTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateContextMethodDescriptor) + .build(); + GrpcCallSettings deleteContextTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteContextMethodDescriptor) + .build(); + GrpcCallSettings deleteAllContextsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteAllContextsMethodDescriptor) + .build(); + + this.listContextsCallable = + callableFactory.createUnaryCallable( + listContextsTransportSettings, settings.listContextsSettings(), clientContext); + this.listContextsPagedCallable = + callableFactory.createPagedCallable( + listContextsTransportSettings, settings.listContextsSettings(), clientContext); + this.getContextCallable = + callableFactory.createUnaryCallable( + getContextTransportSettings, settings.getContextSettings(), clientContext); + this.createContextCallable = + callableFactory.createUnaryCallable( + createContextTransportSettings, settings.createContextSettings(), clientContext); + this.updateContextCallable = + callableFactory.createUnaryCallable( + updateContextTransportSettings, settings.updateContextSettings(), clientContext); + this.deleteContextCallable = + callableFactory.createUnaryCallable( + deleteContextTransportSettings, settings.deleteContextSettings(), clientContext); + this.deleteAllContextsCallable = + callableFactory.createUnaryCallable( + deleteAllContextsTransportSettings, + settings.deleteAllContextsSettings(), + clientContext); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public UnaryCallable listContextsPagedCallable() { + return listContextsPagedCallable; + } + + public UnaryCallable listContextsCallable() { + return listContextsCallable; + } + + public UnaryCallable getContextCallable() { + return getContextCallable; + } + + public UnaryCallable createContextCallable() { + return createContextCallable; + } + + public UnaryCallable updateContextCallable() { + return updateContextCallable; + } + + public UnaryCallable deleteContextCallable() { + return deleteContextCallable; + } + + public UnaryCallable deleteAllContextsCallable() { + return deleteAllContextsCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesCallableFactory.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesCallableFactory.java new file mode 100644 index 000000000000..cb77900166e4 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesCallableFactory.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC callable factory implementation for Dialogflow API. + * + *

This class is for advanced usage. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class GrpcEntityTypesCallableFactory implements GrpcStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, batchingCallSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, operationCallSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesStub.java new file mode 100644 index 000000000000..23c2b805b36a --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcEntityTypesStub.java @@ -0,0 +1,447 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.EntityTypesClient.ListEntityTypesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.BatchCreateEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse; +import com.google.cloud.dialogflow.v2.CreateEntityTypeRequest; +import com.google.cloud.dialogflow.v2.DeleteEntityTypeRequest; +import com.google.cloud.dialogflow.v2.EntityType; +import com.google.cloud.dialogflow.v2.GetEntityTypeRequest; +import com.google.cloud.dialogflow.v2.ListEntityTypesRequest; +import com.google.cloud.dialogflow.v2.ListEntityTypesResponse; +import com.google.cloud.dialogflow.v2.UpdateEntityTypeRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC stub implementation for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class GrpcEntityTypesStub extends EntityTypesStub { + + private static final MethodDescriptor + listEntityTypesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/ListEntityTypes") + .setRequestMarshaller( + ProtoUtils.marshaller(ListEntityTypesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListEntityTypesResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor + getEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/GetEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(GetEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(EntityType.getDefaultInstance())) + .build(); + private static final MethodDescriptor + createEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/CreateEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(EntityType.getDefaultInstance())) + .build(); + private static final MethodDescriptor + updateEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/UpdateEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(EntityType.getDefaultInstance())) + .build(); + private static final MethodDescriptor + deleteEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/DeleteEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + private static final MethodDescriptor + batchUpdateEntityTypesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntityTypes") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchUpdateEntityTypesRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + batchDeleteEntityTypesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntityTypes") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchDeleteEntityTypesRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + batchCreateEntitiesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchCreateEntities") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchCreateEntitiesRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + batchUpdateEntitiesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchUpdateEntities") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchUpdateEntitiesRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + batchDeleteEntitiesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.EntityTypes/BatchDeleteEntities") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchDeleteEntitiesRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + + private final UnaryCallable + listEntityTypesCallable; + private final UnaryCallable + listEntityTypesPagedCallable; + private final UnaryCallable getEntityTypeCallable; + private final UnaryCallable createEntityTypeCallable; + private final UnaryCallable updateEntityTypeCallable; + private final UnaryCallable deleteEntityTypeCallable; + private final UnaryCallable + batchUpdateEntityTypesCallable; + private final OperationCallable< + BatchUpdateEntityTypesRequest, BatchUpdateEntityTypesResponse, Struct> + batchUpdateEntityTypesOperationCallable; + private final UnaryCallable + batchDeleteEntityTypesCallable; + private final OperationCallable + batchDeleteEntityTypesOperationCallable; + private final UnaryCallable batchCreateEntitiesCallable; + private final OperationCallable + batchCreateEntitiesOperationCallable; + private final UnaryCallable batchUpdateEntitiesCallable; + private final OperationCallable + batchUpdateEntitiesOperationCallable; + private final UnaryCallable batchDeleteEntitiesCallable; + private final OperationCallable + batchDeleteEntitiesOperationCallable; + + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcEntityTypesStub create(EntityTypesStubSettings settings) + throws IOException { + return new GrpcEntityTypesStub(settings, ClientContext.create(settings)); + } + + public static final GrpcEntityTypesStub create(ClientContext clientContext) throws IOException { + return new GrpcEntityTypesStub(EntityTypesStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcEntityTypesStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcEntityTypesStub( + EntityTypesStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcEntityTypesStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcEntityTypesStub(EntityTypesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcEntityTypesCallableFactory()); + } + + /** + * Constructs an instance of GrpcEntityTypesStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcEntityTypesStub( + EntityTypesStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings + listEntityTypesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listEntityTypesMethodDescriptor) + .build(); + GrpcCallSettings getEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getEntityTypeMethodDescriptor) + .build(); + GrpcCallSettings createEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createEntityTypeMethodDescriptor) + .build(); + GrpcCallSettings updateEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateEntityTypeMethodDescriptor) + .build(); + GrpcCallSettings deleteEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteEntityTypeMethodDescriptor) + .build(); + GrpcCallSettings + batchUpdateEntityTypesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateEntityTypesMethodDescriptor) + .build(); + GrpcCallSettings + batchDeleteEntityTypesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteEntityTypesMethodDescriptor) + .build(); + GrpcCallSettings batchCreateEntitiesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchCreateEntitiesMethodDescriptor) + .build(); + GrpcCallSettings batchUpdateEntitiesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateEntitiesMethodDescriptor) + .build(); + GrpcCallSettings batchDeleteEntitiesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteEntitiesMethodDescriptor) + .build(); + + this.listEntityTypesCallable = + callableFactory.createUnaryCallable( + listEntityTypesTransportSettings, settings.listEntityTypesSettings(), clientContext); + this.listEntityTypesPagedCallable = + callableFactory.createPagedCallable( + listEntityTypesTransportSettings, settings.listEntityTypesSettings(), clientContext); + this.getEntityTypeCallable = + callableFactory.createUnaryCallable( + getEntityTypeTransportSettings, settings.getEntityTypeSettings(), clientContext); + this.createEntityTypeCallable = + callableFactory.createUnaryCallable( + createEntityTypeTransportSettings, settings.createEntityTypeSettings(), clientContext); + this.updateEntityTypeCallable = + callableFactory.createUnaryCallable( + updateEntityTypeTransportSettings, settings.updateEntityTypeSettings(), clientContext); + this.deleteEntityTypeCallable = + callableFactory.createUnaryCallable( + deleteEntityTypeTransportSettings, settings.deleteEntityTypeSettings(), clientContext); + this.batchUpdateEntityTypesCallable = + callableFactory.createUnaryCallable( + batchUpdateEntityTypesTransportSettings, + settings.batchUpdateEntityTypesSettings(), + clientContext); + this.batchUpdateEntityTypesOperationCallable = + callableFactory.createOperationCallable( + batchUpdateEntityTypesTransportSettings, + settings.batchUpdateEntityTypesOperationSettings(), + clientContext, + this.operationsStub); + this.batchDeleteEntityTypesCallable = + callableFactory.createUnaryCallable( + batchDeleteEntityTypesTransportSettings, + settings.batchDeleteEntityTypesSettings(), + clientContext); + this.batchDeleteEntityTypesOperationCallable = + callableFactory.createOperationCallable( + batchDeleteEntityTypesTransportSettings, + settings.batchDeleteEntityTypesOperationSettings(), + clientContext, + this.operationsStub); + this.batchCreateEntitiesCallable = + callableFactory.createUnaryCallable( + batchCreateEntitiesTransportSettings, + settings.batchCreateEntitiesSettings(), + clientContext); + this.batchCreateEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchCreateEntitiesTransportSettings, + settings.batchCreateEntitiesOperationSettings(), + clientContext, + this.operationsStub); + this.batchUpdateEntitiesCallable = + callableFactory.createUnaryCallable( + batchUpdateEntitiesTransportSettings, + settings.batchUpdateEntitiesSettings(), + clientContext); + this.batchUpdateEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchUpdateEntitiesTransportSettings, + settings.batchUpdateEntitiesOperationSettings(), + clientContext, + this.operationsStub); + this.batchDeleteEntitiesCallable = + callableFactory.createUnaryCallable( + batchDeleteEntitiesTransportSettings, + settings.batchDeleteEntitiesSettings(), + clientContext); + this.batchDeleteEntitiesOperationCallable = + callableFactory.createOperationCallable( + batchDeleteEntitiesTransportSettings, + settings.batchDeleteEntitiesOperationSettings(), + clientContext, + this.operationsStub); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + public UnaryCallable + listEntityTypesPagedCallable() { + return listEntityTypesPagedCallable; + } + + public UnaryCallable listEntityTypesCallable() { + return listEntityTypesCallable; + } + + public UnaryCallable getEntityTypeCallable() { + return getEntityTypeCallable; + } + + public UnaryCallable createEntityTypeCallable() { + return createEntityTypeCallable; + } + + public UnaryCallable updateEntityTypeCallable() { + return updateEntityTypeCallable; + } + + public UnaryCallable deleteEntityTypeCallable() { + return deleteEntityTypeCallable; + } + + public OperationCallable + batchUpdateEntityTypesOperationCallable() { + return batchUpdateEntityTypesOperationCallable; + } + + public UnaryCallable batchUpdateEntityTypesCallable() { + return batchUpdateEntityTypesCallable; + } + + public OperationCallable + batchDeleteEntityTypesOperationCallable() { + return batchDeleteEntityTypesOperationCallable; + } + + public UnaryCallable batchDeleteEntityTypesCallable() { + return batchDeleteEntityTypesCallable; + } + + public OperationCallable + batchCreateEntitiesOperationCallable() { + return batchCreateEntitiesOperationCallable; + } + + public UnaryCallable batchCreateEntitiesCallable() { + return batchCreateEntitiesCallable; + } + + public OperationCallable + batchUpdateEntitiesOperationCallable() { + return batchUpdateEntitiesOperationCallable; + } + + public UnaryCallable batchUpdateEntitiesCallable() { + return batchUpdateEntitiesCallable; + } + + public OperationCallable + batchDeleteEntitiesOperationCallable() { + return batchDeleteEntitiesOperationCallable; + } + + public UnaryCallable batchDeleteEntitiesCallable() { + return batchDeleteEntitiesCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsCallableFactory.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsCallableFactory.java new file mode 100644 index 000000000000..808b1de86590 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsCallableFactory.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC callable factory implementation for Dialogflow API. + * + *

This class is for advanced usage. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class GrpcIntentsCallableFactory implements GrpcStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, batchingCallSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, operationCallSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsStub.java new file mode 100644 index 000000000000..60500b793a24 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcIntentsStub.java @@ -0,0 +1,316 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.IntentsClient.ListIntentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.CreateIntentRequest; +import com.google.cloud.dialogflow.v2.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2.GetIntentRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.ListIntentsRequest; +import com.google.cloud.dialogflow.v2.ListIntentsResponse; +import com.google.cloud.dialogflow.v2.UpdateIntentRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC stub implementation for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class GrpcIntentsStub extends IntentsStub { + + private static final MethodDescriptor + listIntentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Intents/ListIntents") + .setRequestMarshaller(ProtoUtils.marshaller(ListIntentsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListIntentsResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor getIntentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Intents/GetIntent") + .setRequestMarshaller(ProtoUtils.marshaller(GetIntentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Intent.getDefaultInstance())) + .build(); + private static final MethodDescriptor createIntentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Intents/CreateIntent") + .setRequestMarshaller(ProtoUtils.marshaller(CreateIntentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Intent.getDefaultInstance())) + .build(); + private static final MethodDescriptor updateIntentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Intents/UpdateIntent") + .setRequestMarshaller(ProtoUtils.marshaller(UpdateIntentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Intent.getDefaultInstance())) + .build(); + private static final MethodDescriptor deleteIntentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Intents/DeleteIntent") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteIntentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + private static final MethodDescriptor + batchUpdateIntentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Intents/BatchUpdateIntents") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchUpdateIntentsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor + batchDeleteIntentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Intents/BatchDeleteIntents") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchDeleteIntentsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + + private final UnaryCallable listIntentsCallable; + private final UnaryCallable + listIntentsPagedCallable; + private final UnaryCallable getIntentCallable; + private final UnaryCallable createIntentCallable; + private final UnaryCallable updateIntentCallable; + private final UnaryCallable deleteIntentCallable; + private final UnaryCallable batchUpdateIntentsCallable; + private final OperationCallable + batchUpdateIntentsOperationCallable; + private final UnaryCallable batchDeleteIntentsCallable; + private final OperationCallable + batchDeleteIntentsOperationCallable; + + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcIntentsStub create(IntentsStubSettings settings) throws IOException { + return new GrpcIntentsStub(settings, ClientContext.create(settings)); + } + + public static final GrpcIntentsStub create(ClientContext clientContext) throws IOException { + return new GrpcIntentsStub(IntentsStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcIntentsStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcIntentsStub( + IntentsStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcIntentsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcIntentsStub(IntentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcIntentsCallableFactory()); + } + + /** + * Constructs an instance of GrpcIntentsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcIntentsStub( + IntentsStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings listIntentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listIntentsMethodDescriptor) + .build(); + GrpcCallSettings getIntentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getIntentMethodDescriptor) + .build(); + GrpcCallSettings createIntentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createIntentMethodDescriptor) + .build(); + GrpcCallSettings updateIntentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateIntentMethodDescriptor) + .build(); + GrpcCallSettings deleteIntentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteIntentMethodDescriptor) + .build(); + GrpcCallSettings batchUpdateIntentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchUpdateIntentsMethodDescriptor) + .build(); + GrpcCallSettings batchDeleteIntentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchDeleteIntentsMethodDescriptor) + .build(); + + this.listIntentsCallable = + callableFactory.createUnaryCallable( + listIntentsTransportSettings, settings.listIntentsSettings(), clientContext); + this.listIntentsPagedCallable = + callableFactory.createPagedCallable( + listIntentsTransportSettings, settings.listIntentsSettings(), clientContext); + this.getIntentCallable = + callableFactory.createUnaryCallable( + getIntentTransportSettings, settings.getIntentSettings(), clientContext); + this.createIntentCallable = + callableFactory.createUnaryCallable( + createIntentTransportSettings, settings.createIntentSettings(), clientContext); + this.updateIntentCallable = + callableFactory.createUnaryCallable( + updateIntentTransportSettings, settings.updateIntentSettings(), clientContext); + this.deleteIntentCallable = + callableFactory.createUnaryCallable( + deleteIntentTransportSettings, settings.deleteIntentSettings(), clientContext); + this.batchUpdateIntentsCallable = + callableFactory.createUnaryCallable( + batchUpdateIntentsTransportSettings, + settings.batchUpdateIntentsSettings(), + clientContext); + this.batchUpdateIntentsOperationCallable = + callableFactory.createOperationCallable( + batchUpdateIntentsTransportSettings, + settings.batchUpdateIntentsOperationSettings(), + clientContext, + this.operationsStub); + this.batchDeleteIntentsCallable = + callableFactory.createUnaryCallable( + batchDeleteIntentsTransportSettings, + settings.batchDeleteIntentsSettings(), + clientContext); + this.batchDeleteIntentsOperationCallable = + callableFactory.createOperationCallable( + batchDeleteIntentsTransportSettings, + settings.batchDeleteIntentsOperationSettings(), + clientContext, + this.operationsStub); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + public UnaryCallable listIntentsPagedCallable() { + return listIntentsPagedCallable; + } + + public UnaryCallable listIntentsCallable() { + return listIntentsCallable; + } + + public UnaryCallable getIntentCallable() { + return getIntentCallable; + } + + public UnaryCallable createIntentCallable() { + return createIntentCallable; + } + + public UnaryCallable updateIntentCallable() { + return updateIntentCallable; + } + + public UnaryCallable deleteIntentCallable() { + return deleteIntentCallable; + } + + public OperationCallable + batchUpdateIntentsOperationCallable() { + return batchUpdateIntentsOperationCallable; + } + + public UnaryCallable batchUpdateIntentsCallable() { + return batchUpdateIntentsCallable; + } + + public OperationCallable + batchDeleteIntentsOperationCallable() { + return batchDeleteIntentsOperationCallable; + } + + public UnaryCallable batchDeleteIntentsCallable() { + return batchDeleteIntentsCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesCallableFactory.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesCallableFactory.java new file mode 100644 index 000000000000..58242634e199 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesCallableFactory.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC callable factory implementation for Dialogflow API. + * + *

This class is for advanced usage. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class GrpcSessionEntityTypesCallableFactory implements GrpcStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, batchingCallSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, operationCallSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesStub.java new file mode 100644 index 000000000000..7f43c5247021 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionEntityTypesStub.java @@ -0,0 +1,280 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesResponse; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.UpdateSessionEntityTypeRequest; +import com.google.protobuf.Empty; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC stub implementation for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class GrpcSessionEntityTypesStub extends SessionEntityTypesStub { + + private static final MethodDescriptor< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse> + listSessionEntityTypesMethodDescriptor = + MethodDescriptor + .newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/ListSessionEntityTypes") + .setRequestMarshaller( + ProtoUtils.marshaller(ListSessionEntityTypesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListSessionEntityTypesResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor + getSessionEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/GetSessionEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(GetSessionEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(SessionEntityType.getDefaultInstance())) + .build(); + private static final MethodDescriptor + createSessionEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/CreateSessionEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateSessionEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(SessionEntityType.getDefaultInstance())) + .build(); + private static final MethodDescriptor + updateSessionEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/UpdateSessionEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateSessionEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(SessionEntityType.getDefaultInstance())) + .build(); + private static final MethodDescriptor + deleteSessionEntityTypeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.dialogflow.v2.SessionEntityTypes/DeleteSessionEntityType") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteSessionEntityTypeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private final BackgroundResource backgroundResources; + + private final UnaryCallable + listSessionEntityTypesCallable; + private final UnaryCallable + listSessionEntityTypesPagedCallable; + private final UnaryCallable + getSessionEntityTypeCallable; + private final UnaryCallable + createSessionEntityTypeCallable; + private final UnaryCallable + updateSessionEntityTypeCallable; + private final UnaryCallable + deleteSessionEntityTypeCallable; + + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcSessionEntityTypesStub create(SessionEntityTypesStubSettings settings) + throws IOException { + return new GrpcSessionEntityTypesStub(settings, ClientContext.create(settings)); + } + + public static final GrpcSessionEntityTypesStub create(ClientContext clientContext) + throws IOException { + return new GrpcSessionEntityTypesStub( + SessionEntityTypesStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcSessionEntityTypesStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcSessionEntityTypesStub( + SessionEntityTypesStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcSessionEntityTypesStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcSessionEntityTypesStub( + SessionEntityTypesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new GrpcSessionEntityTypesCallableFactory()); + } + + /** + * Constructs an instance of GrpcSessionEntityTypesStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcSessionEntityTypesStub( + SessionEntityTypesStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + GrpcCallSettings + listSessionEntityTypesTransportSettings = + GrpcCallSettings + .newBuilder() + .setMethodDescriptor(listSessionEntityTypesMethodDescriptor) + .build(); + GrpcCallSettings + getSessionEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getSessionEntityTypeMethodDescriptor) + .build(); + GrpcCallSettings + createSessionEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createSessionEntityTypeMethodDescriptor) + .build(); + GrpcCallSettings + updateSessionEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateSessionEntityTypeMethodDescriptor) + .build(); + GrpcCallSettings + deleteSessionEntityTypeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteSessionEntityTypeMethodDescriptor) + .build(); + + this.listSessionEntityTypesCallable = + callableFactory.createUnaryCallable( + listSessionEntityTypesTransportSettings, + settings.listSessionEntityTypesSettings(), + clientContext); + this.listSessionEntityTypesPagedCallable = + callableFactory.createPagedCallable( + listSessionEntityTypesTransportSettings, + settings.listSessionEntityTypesSettings(), + clientContext); + this.getSessionEntityTypeCallable = + callableFactory.createUnaryCallable( + getSessionEntityTypeTransportSettings, + settings.getSessionEntityTypeSettings(), + clientContext); + this.createSessionEntityTypeCallable = + callableFactory.createUnaryCallable( + createSessionEntityTypeTransportSettings, + settings.createSessionEntityTypeSettings(), + clientContext); + this.updateSessionEntityTypeCallable = + callableFactory.createUnaryCallable( + updateSessionEntityTypeTransportSettings, + settings.updateSessionEntityTypeSettings(), + clientContext); + this.deleteSessionEntityTypeCallable = + callableFactory.createUnaryCallable( + deleteSessionEntityTypeTransportSettings, + settings.deleteSessionEntityTypeSettings(), + clientContext); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public UnaryCallable + listSessionEntityTypesPagedCallable() { + return listSessionEntityTypesPagedCallable; + } + + public UnaryCallable + listSessionEntityTypesCallable() { + return listSessionEntityTypesCallable; + } + + public UnaryCallable + getSessionEntityTypeCallable() { + return getSessionEntityTypeCallable; + } + + public UnaryCallable + createSessionEntityTypeCallable() { + return createSessionEntityTypeCallable; + } + + public UnaryCallable + updateSessionEntityTypeCallable() { + return updateSessionEntityTypeCallable; + } + + public UnaryCallable deleteSessionEntityTypeCallable() { + return deleteSessionEntityTypeCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsCallableFactory.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsCallableFactory.java new file mode 100644 index 000000000000..3507a5c9be6e --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsCallableFactory.java @@ -0,0 +1,114 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC callable factory implementation for Dialogflow API. + * + *

This class is for advanced usage. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class GrpcSessionsCallableFactory implements GrpcStubCallableFactory { + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, batchingCallSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, operationCallSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings streamingCallSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, streamingCallSettings, clientContext); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsStub.java new file mode 100644 index 000000000000..d4e24c168300 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/GrpcSessionsStub.java @@ -0,0 +1,169 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.DetectIntentRequest; +import com.google.cloud.dialogflow.v2.DetectIntentResponse; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentRequest; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentResponse; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * gRPC stub implementation for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class GrpcSessionsStub extends SessionsStub { + + private static final MethodDescriptor + detectIntentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.dialogflow.v2.Sessions/DetectIntent") + .setRequestMarshaller(ProtoUtils.marshaller(DetectIntentRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(DetectIntentResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor + streamingDetectIntentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName("google.cloud.dialogflow.v2.Sessions/StreamingDetectIntent") + .setRequestMarshaller( + ProtoUtils.marshaller(StreamingDetectIntentRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(StreamingDetectIntentResponse.getDefaultInstance())) + .build(); + + private final BackgroundResource backgroundResources; + + private final UnaryCallable detectIntentCallable; + private final BidiStreamingCallable + streamingDetectIntentCallable; + + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcSessionsStub create(SessionsStubSettings settings) throws IOException { + return new GrpcSessionsStub(settings, ClientContext.create(settings)); + } + + public static final GrpcSessionsStub create(ClientContext clientContext) throws IOException { + return new GrpcSessionsStub(SessionsStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcSessionsStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcSessionsStub( + SessionsStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcSessionsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcSessionsStub(SessionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcSessionsCallableFactory()); + } + + /** + * Constructs an instance of GrpcSessionsStub, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected GrpcSessionsStub( + SessionsStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + GrpcCallSettings detectIntentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(detectIntentMethodDescriptor) + .build(); + GrpcCallSettings + streamingDetectIntentTransportSettings = + GrpcCallSettings + .newBuilder() + .setMethodDescriptor(streamingDetectIntentMethodDescriptor) + .build(); + + this.detectIntentCallable = + callableFactory.createUnaryCallable( + detectIntentTransportSettings, settings.detectIntentSettings(), clientContext); + this.streamingDetectIntentCallable = + callableFactory.createBidiStreamingCallable( + streamingDetectIntentTransportSettings, + settings.streamingDetectIntentSettings(), + clientContext); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public UnaryCallable detectIntentCallable() { + return detectIntentCallable; + } + + public BidiStreamingCallable + streamingDetectIntentCallable() { + return streamingDetectIntentCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java new file mode 100644 index 000000000000..8b2c89763782 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStub.java @@ -0,0 +1,100 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.IntentsClient.ListIntentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.CreateIntentRequest; +import com.google.cloud.dialogflow.v2.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2.GetIntentRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.ListIntentsRequest; +import com.google.cloud.dialogflow.v2.ListIntentsResponse; +import com.google.cloud.dialogflow.v2.UpdateIntentRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class IntentsStub implements BackgroundResource { + + public OperationsStub getOperationsStub() { + throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + } + + public UnaryCallable listIntentsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listIntentsPagedCallable()"); + } + + public UnaryCallable listIntentsCallable() { + throw new UnsupportedOperationException("Not implemented: listIntentsCallable()"); + } + + public UnaryCallable getIntentCallable() { + throw new UnsupportedOperationException("Not implemented: getIntentCallable()"); + } + + public UnaryCallable createIntentCallable() { + throw new UnsupportedOperationException("Not implemented: createIntentCallable()"); + } + + public UnaryCallable updateIntentCallable() { + throw new UnsupportedOperationException("Not implemented: updateIntentCallable()"); + } + + public UnaryCallable deleteIntentCallable() { + throw new UnsupportedOperationException("Not implemented: deleteIntentCallable()"); + } + + public OperationCallable + batchUpdateIntentsOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: batchUpdateIntentsOperationCallable()"); + } + + public UnaryCallable batchUpdateIntentsCallable() { + throw new UnsupportedOperationException("Not implemented: batchUpdateIntentsCallable()"); + } + + public OperationCallable + batchDeleteIntentsOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: batchDeleteIntentsOperationCallable()"); + } + + public UnaryCallable batchDeleteIntentsCallable() { + throw new UnsupportedOperationException("Not implemented: batchDeleteIntentsCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java new file mode 100644 index 000000000000..cf5d30c05b09 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/IntentsStubSettings.java @@ -0,0 +1,581 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.IntentsClient.ListIntentsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.BatchDeleteIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsRequest; +import com.google.cloud.dialogflow.v2.BatchUpdateIntentsResponse; +import com.google.cloud.dialogflow.v2.CreateIntentRequest; +import com.google.cloud.dialogflow.v2.DeleteIntentRequest; +import com.google.cloud.dialogflow.v2.GetIntentRequest; +import com.google.cloud.dialogflow.v2.Intent; +import com.google.cloud.dialogflow.v2.ListIntentsRequest; +import com.google.cloud.dialogflow.v2.ListIntentsResponse; +import com.google.cloud.dialogflow.v2.UpdateIntentRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.Struct; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link IntentsStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getIntent to 30 seconds: + * + *

+ * 
+ * IntentsStubSettings.Builder intentsSettingsBuilder =
+ *     IntentsStubSettings.newBuilder();
+ * intentsSettingsBuilder.getIntentSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * IntentsStubSettings intentsSettings = intentsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class IntentsStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final PagedCallSettings + listIntentsSettings; + private final UnaryCallSettings getIntentSettings; + private final UnaryCallSettings createIntentSettings; + private final UnaryCallSettings updateIntentSettings; + private final UnaryCallSettings deleteIntentSettings; + private final UnaryCallSettings batchUpdateIntentsSettings; + private final OperationCallSettings + batchUpdateIntentsOperationSettings; + private final UnaryCallSettings batchDeleteIntentsSettings; + private final OperationCallSettings + batchDeleteIntentsOperationSettings; + + /** Returns the object with the settings used for calls to listIntents. */ + public PagedCallSettings + listIntentsSettings() { + return listIntentsSettings; + } + + /** Returns the object with the settings used for calls to getIntent. */ + public UnaryCallSettings getIntentSettings() { + return getIntentSettings; + } + + /** Returns the object with the settings used for calls to createIntent. */ + public UnaryCallSettings createIntentSettings() { + return createIntentSettings; + } + + /** Returns the object with the settings used for calls to updateIntent. */ + public UnaryCallSettings updateIntentSettings() { + return updateIntentSettings; + } + + /** Returns the object with the settings used for calls to deleteIntent. */ + public UnaryCallSettings deleteIntentSettings() { + return deleteIntentSettings; + } + + /** Returns the object with the settings used for calls to batchUpdateIntents. */ + public UnaryCallSettings batchUpdateIntentsSettings() { + return batchUpdateIntentsSettings; + } + + /** Returns the object with the settings used for calls to batchUpdateIntents. */ + public OperationCallSettings + batchUpdateIntentsOperationSettings() { + return batchUpdateIntentsOperationSettings; + } + + /** Returns the object with the settings used for calls to batchDeleteIntents. */ + public UnaryCallSettings batchDeleteIntentsSettings() { + return batchDeleteIntentsSettings; + } + + /** Returns the object with the settings used for calls to batchDeleteIntents. */ + public OperationCallSettings + batchDeleteIntentsOperationSettings() { + return batchDeleteIntentsOperationSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public IntentsStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcIntentsStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "dialogflow.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(IntentsStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected IntentsStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listIntentsSettings = settingsBuilder.listIntentsSettings().build(); + getIntentSettings = settingsBuilder.getIntentSettings().build(); + createIntentSettings = settingsBuilder.createIntentSettings().build(); + updateIntentSettings = settingsBuilder.updateIntentSettings().build(); + deleteIntentSettings = settingsBuilder.deleteIntentSettings().build(); + batchUpdateIntentsSettings = settingsBuilder.batchUpdateIntentsSettings().build(); + batchUpdateIntentsOperationSettings = + settingsBuilder.batchUpdateIntentsOperationSettings().build(); + batchDeleteIntentsSettings = settingsBuilder.batchDeleteIntentsSettings().build(); + batchDeleteIntentsOperationSettings = + settingsBuilder.batchDeleteIntentsOperationSettings().build(); + } + + private static final PagedListDescriptor + LIST_INTENTS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListIntentsRequest injectToken(ListIntentsRequest payload, String token) { + return ListIntentsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListIntentsRequest injectPageSize(ListIntentsRequest payload, int pageSize) { + return ListIntentsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListIntentsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListIntentsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListIntentsResponse payload) { + return payload.getIntentsList(); + } + }; + + private static final PagedListResponseFactory< + ListIntentsRequest, ListIntentsResponse, ListIntentsPagedResponse> + LIST_INTENTS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListIntentsRequest, ListIntentsResponse, ListIntentsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListIntentsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_INTENTS_PAGE_STR_DESC, request, context); + return ListIntentsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Builder for IntentsStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final PagedCallSettings.Builder< + ListIntentsRequest, ListIntentsResponse, ListIntentsPagedResponse> + listIntentsSettings; + private final UnaryCallSettings.Builder getIntentSettings; + private final UnaryCallSettings.Builder createIntentSettings; + private final UnaryCallSettings.Builder updateIntentSettings; + private final UnaryCallSettings.Builder deleteIntentSettings; + private final UnaryCallSettings.Builder + batchUpdateIntentsSettings; + private final OperationCallSettings.Builder< + BatchUpdateIntentsRequest, BatchUpdateIntentsResponse, Struct> + batchUpdateIntentsOperationSettings; + private final UnaryCallSettings.Builder + batchDeleteIntentsSettings; + private final OperationCallSettings.Builder + batchDeleteIntentsOperationSettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listIntentsSettings = PagedCallSettings.newBuilder(LIST_INTENTS_PAGE_STR_FACT); + + getIntentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + createIntentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + updateIntentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + deleteIntentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchUpdateIntentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchUpdateIntentsOperationSettings = OperationCallSettings.newBuilder(); + + batchDeleteIntentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + batchDeleteIntentsOperationSettings = OperationCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listIntentsSettings, + getIntentSettings, + createIntentSettings, + updateIntentSettings, + deleteIntentSettings, + batchUpdateIntentsSettings, + batchDeleteIntentsSettings); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder + .listIntentsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .getIntentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .createIntentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .updateIntentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .deleteIntentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .batchUpdateIntentsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .batchDeleteIntentsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder + .batchUpdateIntentsOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create( + BatchUpdateIntentsResponse.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .batchDeleteIntentsOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(Struct.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + return builder; + } + + protected Builder(IntentsStubSettings settings) { + super(settings); + + listIntentsSettings = settings.listIntentsSettings.toBuilder(); + getIntentSettings = settings.getIntentSettings.toBuilder(); + createIntentSettings = settings.createIntentSettings.toBuilder(); + updateIntentSettings = settings.updateIntentSettings.toBuilder(); + deleteIntentSettings = settings.deleteIntentSettings.toBuilder(); + batchUpdateIntentsSettings = settings.batchUpdateIntentsSettings.toBuilder(); + batchUpdateIntentsOperationSettings = + settings.batchUpdateIntentsOperationSettings.toBuilder(); + batchDeleteIntentsSettings = settings.batchDeleteIntentsSettings.toBuilder(); + batchDeleteIntentsOperationSettings = + settings.batchDeleteIntentsOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listIntentsSettings, + getIntentSettings, + createIntentSettings, + updateIntentSettings, + deleteIntentSettings, + batchUpdateIntentsSettings, + batchDeleteIntentsSettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to listIntents. */ + public PagedCallSettings.Builder< + ListIntentsRequest, ListIntentsResponse, ListIntentsPagedResponse> + listIntentsSettings() { + return listIntentsSettings; + } + + /** Returns the builder for the settings used for calls to getIntent. */ + public UnaryCallSettings.Builder getIntentSettings() { + return getIntentSettings; + } + + /** Returns the builder for the settings used for calls to createIntent. */ + public UnaryCallSettings.Builder createIntentSettings() { + return createIntentSettings; + } + + /** Returns the builder for the settings used for calls to updateIntent. */ + public UnaryCallSettings.Builder updateIntentSettings() { + return updateIntentSettings; + } + + /** Returns the builder for the settings used for calls to deleteIntent. */ + public UnaryCallSettings.Builder deleteIntentSettings() { + return deleteIntentSettings; + } + + /** Returns the builder for the settings used for calls to batchUpdateIntents. */ + public UnaryCallSettings.Builder + batchUpdateIntentsSettings() { + return batchUpdateIntentsSettings; + } + + /** Returns the builder for the settings used for calls to batchUpdateIntents. */ + public OperationCallSettings.Builder< + BatchUpdateIntentsRequest, BatchUpdateIntentsResponse, Struct> + batchUpdateIntentsOperationSettings() { + return batchUpdateIntentsOperationSettings; + } + + /** Returns the builder for the settings used for calls to batchDeleteIntents. */ + public UnaryCallSettings.Builder + batchDeleteIntentsSettings() { + return batchDeleteIntentsSettings; + } + + /** Returns the builder for the settings used for calls to batchDeleteIntents. */ + public OperationCallSettings.Builder + batchDeleteIntentsOperationSettings() { + return batchDeleteIntentsOperationSettings; + } + + @Override + public IntentsStubSettings build() throws IOException { + return new IntentsStubSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStub.java new file mode 100644 index 000000000000..b3582d0eaa86 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStub.java @@ -0,0 +1,75 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesResponse; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.UpdateSessionEntityTypeRequest; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class SessionEntityTypesStub implements BackgroundResource { + + public UnaryCallable + listSessionEntityTypesPagedCallable() { + throw new UnsupportedOperationException( + "Not implemented: listSessionEntityTypesPagedCallable()"); + } + + public UnaryCallable + listSessionEntityTypesCallable() { + throw new UnsupportedOperationException("Not implemented: listSessionEntityTypesCallable()"); + } + + public UnaryCallable + getSessionEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: getSessionEntityTypeCallable()"); + } + + public UnaryCallable + createSessionEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: createSessionEntityTypeCallable()"); + } + + public UnaryCallable + updateSessionEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: updateSessionEntityTypeCallable()"); + } + + public UnaryCallable deleteSessionEntityTypeCallable() { + throw new UnsupportedOperationException("Not implemented: deleteSessionEntityTypeCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java new file mode 100644 index 000000000000..8bbf3ed43967 --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionEntityTypesStubSettings.java @@ -0,0 +1,468 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import static com.google.cloud.dialogflow.v2.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.CreateSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.DeleteSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.GetSessionEntityTypeRequest; +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesRequest; +import com.google.cloud.dialogflow.v2.ListSessionEntityTypesResponse; +import com.google.cloud.dialogflow.v2.SessionEntityType; +import com.google.cloud.dialogflow.v2.UpdateSessionEntityTypeRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SessionEntityTypesStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of getSessionEntityType to 30 seconds: + * + *

+ * 
+ * SessionEntityTypesStubSettings.Builder sessionEntityTypesSettingsBuilder =
+ *     SessionEntityTypesStubSettings.newBuilder();
+ * sessionEntityTypesSettingsBuilder.getSessionEntityTypeSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * SessionEntityTypesStubSettings sessionEntityTypesSettings = sessionEntityTypesSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class SessionEntityTypesStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final PagedCallSettings< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse> + listSessionEntityTypesSettings; + private final UnaryCallSettings + getSessionEntityTypeSettings; + private final UnaryCallSettings + createSessionEntityTypeSettings; + private final UnaryCallSettings + updateSessionEntityTypeSettings; + private final UnaryCallSettings + deleteSessionEntityTypeSettings; + + /** Returns the object with the settings used for calls to listSessionEntityTypes. */ + public PagedCallSettings< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse> + listSessionEntityTypesSettings() { + return listSessionEntityTypesSettings; + } + + /** Returns the object with the settings used for calls to getSessionEntityType. */ + public UnaryCallSettings + getSessionEntityTypeSettings() { + return getSessionEntityTypeSettings; + } + + /** Returns the object with the settings used for calls to createSessionEntityType. */ + public UnaryCallSettings + createSessionEntityTypeSettings() { + return createSessionEntityTypeSettings; + } + + /** Returns the object with the settings used for calls to updateSessionEntityType. */ + public UnaryCallSettings + updateSessionEntityTypeSettings() { + return updateSessionEntityTypeSettings; + } + + /** Returns the object with the settings used for calls to deleteSessionEntityType. */ + public UnaryCallSettings + deleteSessionEntityTypeSettings() { + return deleteSessionEntityTypeSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SessionEntityTypesStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcSessionEntityTypesStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "dialogflow.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SessionEntityTypesStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SessionEntityTypesStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listSessionEntityTypesSettings = settingsBuilder.listSessionEntityTypesSettings().build(); + getSessionEntityTypeSettings = settingsBuilder.getSessionEntityTypeSettings().build(); + createSessionEntityTypeSettings = settingsBuilder.createSessionEntityTypeSettings().build(); + updateSessionEntityTypeSettings = settingsBuilder.updateSessionEntityTypeSettings().build(); + deleteSessionEntityTypeSettings = settingsBuilder.deleteSessionEntityTypeSettings().build(); + } + + private static final PagedListDescriptor< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType> + LIST_SESSION_ENTITY_TYPES_PAGE_STR_DESC = + new PagedListDescriptor< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, SessionEntityType>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListSessionEntityTypesRequest injectToken( + ListSessionEntityTypesRequest payload, String token) { + return ListSessionEntityTypesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListSessionEntityTypesRequest injectPageSize( + ListSessionEntityTypesRequest payload, int pageSize) { + return ListSessionEntityTypesRequest.newBuilder(payload) + .setPageSize(pageSize) + .build(); + } + + @Override + public Integer extractPageSize(ListSessionEntityTypesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListSessionEntityTypesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources( + ListSessionEntityTypesResponse payload) { + return payload.getSessionEntityTypesList(); + } + }; + + private static final PagedListResponseFactory< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse> + LIST_SESSION_ENTITY_TYPES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable + callable, + ListSessionEntityTypesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + SessionEntityType> + pageContext = + PageContext.create( + callable, LIST_SESSION_ENTITY_TYPES_PAGE_STR_DESC, request, context); + return ListSessionEntityTypesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Builder for SessionEntityTypesStubSettings. */ + public static class Builder + extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final PagedCallSettings.Builder< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse> + listSessionEntityTypesSettings; + private final UnaryCallSettings.Builder + getSessionEntityTypeSettings; + private final UnaryCallSettings.Builder + createSessionEntityTypeSettings; + private final UnaryCallSettings.Builder + updateSessionEntityTypeSettings; + private final UnaryCallSettings.Builder + deleteSessionEntityTypeSettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listSessionEntityTypesSettings = + PagedCallSettings.newBuilder(LIST_SESSION_ENTITY_TYPES_PAGE_STR_FACT); + + getSessionEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + createSessionEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + updateSessionEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + deleteSessionEntityTypeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listSessionEntityTypesSettings, + getSessionEntityTypeSettings, + createSessionEntityTypeSettings, + updateSessionEntityTypeSettings, + deleteSessionEntityTypeSettings); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder + .listSessionEntityTypesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .getSessionEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .createSessionEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .updateSessionEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder + .deleteSessionEntityTypeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + return builder; + } + + protected Builder(SessionEntityTypesStubSettings settings) { + super(settings); + + listSessionEntityTypesSettings = settings.listSessionEntityTypesSettings.toBuilder(); + getSessionEntityTypeSettings = settings.getSessionEntityTypeSettings.toBuilder(); + createSessionEntityTypeSettings = settings.createSessionEntityTypeSettings.toBuilder(); + updateSessionEntityTypeSettings = settings.updateSessionEntityTypeSettings.toBuilder(); + deleteSessionEntityTypeSettings = settings.deleteSessionEntityTypeSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listSessionEntityTypesSettings, + getSessionEntityTypeSettings, + createSessionEntityTypeSettings, + updateSessionEntityTypeSettings, + deleteSessionEntityTypeSettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to listSessionEntityTypes. */ + public PagedCallSettings.Builder< + ListSessionEntityTypesRequest, ListSessionEntityTypesResponse, + ListSessionEntityTypesPagedResponse> + listSessionEntityTypesSettings() { + return listSessionEntityTypesSettings; + } + + /** Returns the builder for the settings used for calls to getSessionEntityType. */ + public UnaryCallSettings.Builder + getSessionEntityTypeSettings() { + return getSessionEntityTypeSettings; + } + + /** Returns the builder for the settings used for calls to createSessionEntityType. */ + public UnaryCallSettings.Builder + createSessionEntityTypeSettings() { + return createSessionEntityTypeSettings; + } + + /** Returns the builder for the settings used for calls to updateSessionEntityType. */ + public UnaryCallSettings.Builder + updateSessionEntityTypeSettings() { + return updateSessionEntityTypeSettings; + } + + /** Returns the builder for the settings used for calls to deleteSessionEntityType. */ + public UnaryCallSettings.Builder + deleteSessionEntityTypeSettings() { + return deleteSessionEntityTypeSettings; + } + + @Override + public SessionEntityTypesStubSettings build() throws IOException { + return new SessionEntityTypesStubSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStub.java new file mode 100644 index 000000000000..8c3cd0cc8dba --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStub.java @@ -0,0 +1,49 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.dialogflow.v2.DetectIntentRequest; +import com.google.cloud.dialogflow.v2.DetectIntentResponse; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentRequest; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentResponse; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Dialogflow API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by GAPIC v0.0.5") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class SessionsStub implements BackgroundResource { + + public UnaryCallable detectIntentCallable() { + throw new UnsupportedOperationException("Not implemented: detectIntentCallable()"); + } + + public BidiStreamingCallable + streamingDetectIntentCallable() { + throw new UnsupportedOperationException("Not implemented: streamingDetectIntentCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java new file mode 100644 index 000000000000..d28fca4a6e5b --- /dev/null +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/SessionsStubSettings.java @@ -0,0 +1,290 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2.stub; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.dialogflow.v2.DetectIntentRequest; +import com.google.cloud.dialogflow.v2.DetectIntentResponse; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentRequest; +import com.google.cloud.dialogflow.v2.StreamingDetectIntentResponse; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link SessionsStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (dialogflow.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. For + * example, to set the total timeout of detectIntent to 30 seconds: + * + *

+ * 
+ * SessionsStubSettings.Builder sessionsSettingsBuilder =
+ *     SessionsStubSettings.newBuilder();
+ * sessionsSettingsBuilder.detectIntentSettings().getRetrySettings().toBuilder()
+ *     .setTotalTimeout(Duration.ofSeconds(30));
+ * SessionsStubSettings sessionsSettings = sessionsSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by GAPIC v0.0.5") +@BetaApi +public class SessionsStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final UnaryCallSettings detectIntentSettings; + private final StreamingCallSettings + streamingDetectIntentSettings; + + /** Returns the object with the settings used for calls to detectIntent. */ + public UnaryCallSettings detectIntentSettings() { + return detectIntentSettings; + } + + /** Returns the object with the settings used for calls to streamingDetectIntent. */ + public StreamingCallSettings + streamingDetectIntentSettings() { + return streamingDetectIntentSettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public SessionsStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcSessionsStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "dialogflow.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SessionsStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected SessionsStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + detectIntentSettings = settingsBuilder.detectIntentSettings().build(); + streamingDetectIntentSettings = settingsBuilder.streamingDetectIntentSettings().build(); + } + + /** Builder for SessionsStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final UnaryCallSettings.Builder + detectIntentSettings; + private final StreamingCallSettings.Builder< + StreamingDetectIntentRequest, StreamingDetectIntentResponse> + streamingDetectIntentSettings; + + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + detectIntentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + streamingDetectIntentSettings = StreamingCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of(detectIntentSettings); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder + .detectIntentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + return builder; + } + + protected Builder(SessionsStubSettings settings) { + super(settings); + + detectIntentSettings = settings.detectIntentSettings.toBuilder(); + streamingDetectIntentSettings = settings.streamingDetectIntentSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of(detectIntentSettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to detectIntent. */ + public UnaryCallSettings.Builder + detectIntentSettings() { + return detectIntentSettings; + } + + /** Returns the builder for the settings used for calls to streamingDetectIntent. */ + public StreamingCallSettings.Builder< + StreamingDetectIntentRequest, StreamingDetectIntentResponse> + streamingDetectIntentSettings() { + return streamingDetectIntentSettings; + } + + @Override + public SessionsStubSettings build() throws IOException { + return new SessionsStubSettings(this); + } + } +} diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java index 0fc75eabdda1..17f995d85f9d 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsClient.java @@ -877,7 +877,7 @@ public final UnaryCallable restoreAgentCallable( } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java index 9394c65c58f0..1fdf2c27b594 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/AgentsSettings.java @@ -201,6 +201,7 @@ public AgentsStubSettings.Builder getStubSettingsBuilder() { return ((AgentsStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java index 88855a47b962..5a8779e73b3f 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsClient.java @@ -782,7 +782,7 @@ public final UnaryCallable deleteAllContextsCal } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java index ce833dba8b54..5d746aa91bfe 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/ContextsSettings.java @@ -177,6 +177,7 @@ public ContextsStubSettings.Builder getStubSettingsBuilder() { return ((ContextsStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java index c8c3b3ddc506..eb881004f37a 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesClient.java @@ -1831,7 +1831,7 @@ public final UnaryCallable batchDeleteEnt } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java index beb9b888758d..5c910eb94051 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/EntityTypesSettings.java @@ -234,6 +234,7 @@ public EntityTypesStubSettings.Builder getStubSettingsBuilder() { return ((EntityTypesStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java index db4e8d8253ea..989a53ee5ba8 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsClient.java @@ -1150,7 +1150,7 @@ public final UnaryCallable batchDeleteInte } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java index 2e30f8128970..e8a86ce8fa84 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/IntentsSettings.java @@ -197,6 +197,7 @@ public IntentsStubSettings.Builder getStubSettingsBuilder() { return ((IntentsStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java index 14055fa14faf..c890c97b4e74 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesClient.java @@ -703,7 +703,7 @@ private final void deleteSessionEntityType(DeleteSessionEntityTypeRequest reques } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java index 84c6f739f23f..dc3724bbef55 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionEntityTypesSettings.java @@ -179,6 +179,7 @@ public SessionEntityTypesStubSettings.Builder getStubSettingsBuilder() { return ((SessionEntityTypesStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java index 8e8c9473dc7f..d2e9b23907ae 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsClient.java @@ -323,7 +323,7 @@ public final UnaryCallable detectInte } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java index 6d5679e05800..d004406a2805 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/SessionsSettings.java @@ -154,6 +154,7 @@ public SessionsStubSettings.Builder getStubSettingsBuilder() { return ((SessionsStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java index 4c4c3b7dc3ff..81ce75b17e32 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStub.java @@ -94,4 +94,7 @@ public OperationCallable restoreAgentOperati public UnaryCallable restoreAgentCallable() { throw new UnsupportedOperationException("Not implemented: restoreAgentCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java index fd6a46f944e1..12bb237682af 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/AgentsStubSettings.java @@ -546,6 +546,7 @@ protected Builder(AgentsStubSettings settings) { restoreAgentSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStub.java index a140198361de..cb82bab95544 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStub.java @@ -68,4 +68,7 @@ public UnaryCallable deleteContextCallable() { public UnaryCallable deleteAllContextsCallable() { throw new UnsupportedOperationException("Not implemented: deleteAllContextsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java index 6f68c9b66b2c..a34f7f0381f0 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/ContextsStubSettings.java @@ -399,6 +399,7 @@ protected Builder(ContextsStubSettings settings) { deleteAllContextsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java index 93b1463cfa26..519e5199f450 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStub.java @@ -128,4 +128,7 @@ public UnaryCallable batchUpdateEntitiesC public UnaryCallable batchDeleteEntitiesCallable() { throw new UnsupportedOperationException("Not implemented: batchDeleteEntitiesCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java index 98fd63103608..b07935f78405 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/EntityTypesStubSettings.java @@ -700,6 +700,7 @@ protected Builder(EntityTypesStubSettings settings) { batchDeleteEntitiesSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcAgentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcAgentsStub.java index 9f4f9601b9fb..f85162211a96 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcAgentsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcAgentsStub.java @@ -278,7 +278,7 @@ public UnaryCallable restoreAgentCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcContextsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcContextsStub.java index 26595cdc9de3..8eea2e47cc8e 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcContextsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcContextsStub.java @@ -228,7 +228,7 @@ public UnaryCallable deleteAllContextsCallable( } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcEntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcEntityTypesStub.java index 4afec22e4536..297751ddb969 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcEntityTypesStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcEntityTypesStub.java @@ -418,7 +418,7 @@ public UnaryCallable batchDeleteEntitiesC } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcIntentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcIntentsStub.java index b1c1226755cb..03cf49c34c26 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcIntentsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcIntentsStub.java @@ -285,7 +285,7 @@ public UnaryCallable batchDeleteIntentsCal } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionEntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionEntityTypesStub.java index 235aeb86b925..8924caf279b6 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionEntityTypesStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionEntityTypesStub.java @@ -249,7 +249,7 @@ public UnaryCallable deleteSessionEntityT } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionsStub.java index a16c856ee7cf..7112923e31a0 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/GrpcSessionsStub.java @@ -138,7 +138,7 @@ public UnaryCallable detectIntentCall } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java index 44516c4e2ed1..118589a60553 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStub.java @@ -94,4 +94,7 @@ public UnaryCallable batchUpdateIntentsCal public UnaryCallable batchDeleteIntentsCallable() { throw new UnsupportedOperationException("Not implemented: batchDeleteIntentsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java index f6a7b01a65ba..2abfeecc08fc 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/IntentsStubSettings.java @@ -505,6 +505,7 @@ protected Builder(IntentsStubSettings settings) { batchDeleteIntentsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStub.java index 03eebfec7af1..02fce1f78628 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStub.java @@ -69,4 +69,7 @@ public abstract class SessionEntityTypesStub implements BackgroundResource { public UnaryCallable deleteSessionEntityTypeCallable() { throw new UnsupportedOperationException("Not implemented: deleteSessionEntityTypeCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java index f0fe09c5512c..ad444efc78e5 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionEntityTypesStubSettings.java @@ -412,6 +412,7 @@ protected Builder(SessionEntityTypesStubSettings settings) { deleteSessionEntityTypeSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStub.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStub.java index 88b02acedfa7..f42349292b23 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStub.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStub.java @@ -43,4 +43,7 @@ public UnaryCallable detectIntentCall streamingDetectIntentCallable() { throw new UnsupportedOperationException("Not implemented: streamingDetectIntentCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java index 7c33c6e0f4c0..8a7961317a51 100644 --- a/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java +++ b/google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2beta1/stub/SessionsStubSettings.java @@ -253,6 +253,7 @@ protected Builder(SessionsStubSettings settings) { ImmutableList.>of(detectIntentSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientTest.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientTest.java new file mode 100644 index 000000000000..ef4d104c64f9 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/AgentsClientTest.java @@ -0,0 +1,298 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.AgentsClient.SearchAgentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class AgentsClientTest { + private static MockAgents mockAgents; + private static MockContexts mockContexts; + private static MockEntityTypes mockEntityTypes; + private static MockIntents mockIntents; + private static MockSessionEntityTypes mockSessionEntityTypes; + private static MockSessions mockSessions; + private static MockServiceHelper serviceHelper; + private AgentsClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockAgents = new MockAgents(); + mockContexts = new MockContexts(); + mockEntityTypes = new MockEntityTypes(); + mockIntents = new MockIntents(); + mockSessionEntityTypes = new MockSessionEntityTypes(); + mockSessions = new MockSessions(); + serviceHelper = + new MockServiceHelper( + "in-process-1", + Arrays.asList( + mockAgents, + mockContexts, + mockEntityTypes, + mockIntents, + mockSessionEntityTypes, + mockSessions)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + AgentsSettings settings = + AgentsSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AgentsClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void getAgentTest() { + String parent2 = "parent21175163357"; + String displayName = "displayName1615086568"; + String defaultLanguageCode = "defaultLanguageCode856575222"; + String timeZone = "timeZone36848094"; + String description = "description-1724546052"; + String avatarUri = "avatarUri-402824826"; + boolean enableLogging = false; + float classificationThreshold = 1.11581064E8F; + Agent expectedResponse = + Agent.newBuilder() + .setParent(parent2) + .setDisplayName(displayName) + .setDefaultLanguageCode(defaultLanguageCode) + .setTimeZone(timeZone) + .setDescription(description) + .setAvatarUri(avatarUri) + .setEnableLogging(enableLogging) + .setClassificationThreshold(classificationThreshold) + .build(); + mockAgents.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + Agent actualResponse = client.getAgent(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAgents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetAgentRequest actualRequest = (GetAgentRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getAgentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockAgents.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.getAgent(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void searchAgentsTest() { + String nextPageToken = ""; + Agent agentsElement = Agent.newBuilder().build(); + List agents = Arrays.asList(agentsElement); + SearchAgentsResponse expectedResponse = + SearchAgentsResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllAgents(agents) + .build(); + mockAgents.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + SearchAgentsPagedResponse pagedListResponse = client.searchAgents(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAgentsList().get(0), resources.get(0)); + + List actualRequests = mockAgents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SearchAgentsRequest actualRequest = (SearchAgentsRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void searchAgentsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockAgents.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.searchAgents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void trainAgentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("trainAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockAgents.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + Empty actualResponse = client.trainAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAgents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + TrainAgentRequest actualRequest = (TrainAgentRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void trainAgentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockAgents.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.trainAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void exportAgentTest() throws Exception { + String agentUri = "agentUri-1700713166"; + ExportAgentResponse expectedResponse = + ExportAgentResponse.newBuilder().setAgentUri(agentUri).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportAgentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockAgents.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ExportAgentResponse actualResponse = client.exportAgentAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAgents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ExportAgentRequest actualRequest = (ExportAgentRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void exportAgentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockAgents.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.exportAgentAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientTest.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientTest.java new file mode 100644 index 000000000000..452d5d09ebe2 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/ContextsClientTest.java @@ -0,0 +1,344 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class ContextsClientTest { + private static MockAgents mockAgents; + private static MockContexts mockContexts; + private static MockEntityTypes mockEntityTypes; + private static MockIntents mockIntents; + private static MockSessionEntityTypes mockSessionEntityTypes; + private static MockSessions mockSessions; + private static MockServiceHelper serviceHelper; + private ContextsClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockAgents = new MockAgents(); + mockContexts = new MockContexts(); + mockEntityTypes = new MockEntityTypes(); + mockIntents = new MockIntents(); + mockSessionEntityTypes = new MockSessionEntityTypes(); + mockSessions = new MockSessions(); + serviceHelper = + new MockServiceHelper( + "in-process-1", + Arrays.asList( + mockAgents, + mockContexts, + mockEntityTypes, + mockIntents, + mockSessionEntityTypes, + mockSessions)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + ContextsSettings settings = + ContextsSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ContextsClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void listContextsTest() { + String nextPageToken = ""; + Context contextsElement = Context.newBuilder().build(); + List contexts = Arrays.asList(contextsElement); + ListContextsResponse expectedResponse = + ListContextsResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllContexts(contexts) + .build(); + mockContexts.addResponse(expectedResponse); + + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + + ListContextsPagedResponse pagedListResponse = client.listContexts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getContextsList().get(0), resources.get(0)); + + List actualRequests = mockContexts.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListContextsRequest actualRequest = (ListContextsRequest) actualRequests.get(0); + + Assert.assertEquals(parent, SessionName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listContextsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockContexts.addException(exception); + + try { + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + + client.listContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getContextTest() { + ContextName name2 = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]"); + int lifespanCount = 1178775510; + Context expectedResponse = + Context.newBuilder().setName(name2.toString()).setLifespanCount(lifespanCount).build(); + mockContexts.addResponse(expectedResponse); + + ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + Context actualResponse = client.getContext(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockContexts.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetContextRequest actualRequest = (GetContextRequest) actualRequests.get(0); + + Assert.assertEquals(name, ContextName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getContextExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockContexts.addException(exception); + + try { + ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + client.getContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createContextTest() { + ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]"); + int lifespanCount = 1178775510; + Context expectedResponse = + Context.newBuilder().setName(name.toString()).setLifespanCount(lifespanCount).build(); + mockContexts.addResponse(expectedResponse); + + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + + Context actualResponse = client.createContext(parent, context); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockContexts.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateContextRequest actualRequest = (CreateContextRequest) actualRequests.get(0); + + Assert.assertEquals(parent, SessionName.parse(actualRequest.getParent())); + Assert.assertEquals(context, actualRequest.getContext()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createContextExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockContexts.addException(exception); + + try { + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + Context context = Context.newBuilder().build(); + + client.createContext(parent, context); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateContextTest() { + ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]"); + int lifespanCount = 1178775510; + Context expectedResponse = + Context.newBuilder().setName(name.toString()).setLifespanCount(lifespanCount).build(); + mockContexts.addResponse(expectedResponse); + + Context context = Context.newBuilder().build(); + + Context actualResponse = client.updateContext(context); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockContexts.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateContextRequest actualRequest = (UpdateContextRequest) actualRequests.get(0); + + Assert.assertEquals(context, actualRequest.getContext()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void updateContextExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockContexts.addException(exception); + + try { + Context context = Context.newBuilder().build(); + + client.updateContext(context); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteContextTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockContexts.addResponse(expectedResponse); + + ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + client.deleteContext(name); + + List actualRequests = mockContexts.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteContextRequest actualRequest = (DeleteContextRequest) actualRequests.get(0); + + Assert.assertEquals(name, ContextName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteContextExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockContexts.addException(exception); + + try { + ContextName name = ContextName.of("[PROJECT]", "[SESSION]", "[CONTEXT]"); + + client.deleteContext(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteAllContextsTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockContexts.addResponse(expectedResponse); + + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + + client.deleteAllContexts(parent); + + List actualRequests = mockContexts.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteAllContextsRequest actualRequest = (DeleteAllContextsRequest) actualRequests.get(0); + + Assert.assertEquals(parent, SessionName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteAllContextsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockContexts.addException(exception); + + try { + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + + client.deleteAllContexts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientTest.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientTest.java new file mode 100644 index 000000000000..e7d737f3d3f6 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/EntityTypesClientTest.java @@ -0,0 +1,853 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.EntityTypesClient.ListEntityTypesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.cloud.dialogflow.v2.EntityType.Entity; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class EntityTypesClientTest { + private static MockAgents mockAgents; + private static MockContexts mockContexts; + private static MockEntityTypes mockEntityTypes; + private static MockIntents mockIntents; + private static MockSessionEntityTypes mockSessionEntityTypes; + private static MockSessions mockSessions; + private static MockServiceHelper serviceHelper; + private EntityTypesClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockAgents = new MockAgents(); + mockContexts = new MockContexts(); + mockEntityTypes = new MockEntityTypes(); + mockIntents = new MockIntents(); + mockSessionEntityTypes = new MockSessionEntityTypes(); + mockSessions = new MockSessions(); + serviceHelper = + new MockServiceHelper( + "in-process-1", + Arrays.asList( + mockAgents, + mockContexts, + mockEntityTypes, + mockIntents, + mockSessionEntityTypes, + mockSessions)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + EntityTypesSettings settings = + EntityTypesSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = EntityTypesClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void listEntityTypesTest() { + String nextPageToken = ""; + EntityType entityTypesElement = EntityType.newBuilder().build(); + List entityTypes = Arrays.asList(entityTypesElement); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllEntityTypes(entityTypes) + .build(); + mockEntityTypes.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + + ListEntityTypesPagedResponse pagedListResponse = client.listEntityTypes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEntityTypesList().get(0), resources.get(0)); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListEntityTypesRequest actualRequest = (ListEntityTypesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listEntityTypesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + + client.listEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listEntityTypesTest2() { + String nextPageToken = ""; + EntityType entityTypesElement = EntityType.newBuilder().build(); + List entityTypes = Arrays.asList(entityTypesElement); + ListEntityTypesResponse expectedResponse = + ListEntityTypesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllEntityTypes(entityTypes) + .build(); + mockEntityTypes.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + String languageCode = "languageCode-412800396"; + + ListEntityTypesPagedResponse pagedListResponse = client.listEntityTypes(parent, languageCode); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEntityTypesList().get(0), resources.get(0)); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListEntityTypesRequest actualRequest = (ListEntityTypesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listEntityTypesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + String languageCode = "languageCode-412800396"; + + client.listEntityTypes(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getEntityTypeTest() { + EntityTypeName name2 = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String displayName = "displayName1615086568"; + EntityType expectedResponse = + EntityType.newBuilder().setName(name2.toString()).setDisplayName(displayName).build(); + mockEntityTypes.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + + EntityType actualResponse = client.getEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetEntityTypeRequest actualRequest = (GetEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(name, EntityTypeName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + + client.getEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getEntityTypeTest2() { + EntityTypeName name2 = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String displayName = "displayName1615086568"; + EntityType expectedResponse = + EntityType.newBuilder().setName(name2.toString()).setDisplayName(displayName).build(); + mockEntityTypes.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-412800396"; + + EntityType actualResponse = client.getEntityType(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetEntityTypeRequest actualRequest = (GetEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(name, EntityTypeName.parse(actualRequest.getName())); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getEntityTypeExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String languageCode = "languageCode-412800396"; + + client.getEntityType(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createEntityTypeTest() { + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String displayName = "displayName1615086568"; + EntityType expectedResponse = + EntityType.newBuilder().setName(name.toString()).setDisplayName(displayName).build(); + mockEntityTypes.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + + EntityType actualResponse = client.createEntityType(parent, entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateEntityTypeRequest actualRequest = (CreateEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(entityType, actualRequest.getEntityType()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + + client.createEntityType(parent, entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createEntityTypeTest2() { + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String displayName = "displayName1615086568"; + EntityType expectedResponse = + EntityType.newBuilder().setName(name.toString()).setDisplayName(displayName).build(); + mockEntityTypes.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + EntityType actualResponse = client.createEntityType(parent, entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateEntityTypeRequest actualRequest = (CreateEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(entityType, actualRequest.getEntityType()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createEntityTypeExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + client.createEntityType(parent, entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateEntityTypeTest() { + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String displayName = "displayName1615086568"; + EntityType expectedResponse = + EntityType.newBuilder().setName(name.toString()).setDisplayName(displayName).build(); + mockEntityTypes.addResponse(expectedResponse); + + EntityType entityType = EntityType.newBuilder().build(); + + EntityType actualResponse = client.updateEntityType(entityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateEntityTypeRequest actualRequest = (UpdateEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(entityType, actualRequest.getEntityType()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void updateEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityType entityType = EntityType.newBuilder().build(); + + client.updateEntityType(entityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateEntityTypeTest2() { + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + String displayName = "displayName1615086568"; + EntityType expectedResponse = + EntityType.newBuilder().setName(name.toString()).setDisplayName(displayName).build(); + mockEntityTypes.addResponse(expectedResponse); + + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + EntityType actualResponse = client.updateEntityType(entityType, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateEntityTypeRequest actualRequest = (UpdateEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(entityType, actualRequest.getEntityType()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void updateEntityTypeExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityType entityType = EntityType.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + client.updateEntityType(entityType, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteEntityTypeTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockEntityTypes.addResponse(expectedResponse); + + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + + client.deleteEntityType(name); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteEntityTypeRequest actualRequest = (DeleteEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(name, EntityTypeName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName name = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + + client.deleteEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void batchDeleteEntityTypesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntityTypesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockEntityTypes.addResponse(resultOperation); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + + Empty actualResponse = client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchDeleteEntityTypesRequest actualRequest = + (BatchDeleteEntityTypesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(entityTypeNames, actualRequest.getEntityTypeNamesList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchDeleteEntityTypesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + List entityTypeNames = new ArrayList<>(); + + client.batchDeleteEntityTypesAsync(parent, entityTypeNames).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void batchCreateEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockEntityTypes.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + Empty actualResponse = client.batchCreateEntitiesAsync(parent, entities).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchCreateEntitiesRequest actualRequest = (BatchCreateEntitiesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, EntityTypeName.parse(actualRequest.getParent())); + Assert.assertEquals(entities, actualRequest.getEntitiesList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchCreateEntitiesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + client.batchCreateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void batchCreateEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchCreateEntitiesTest2") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockEntityTypes.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-412800396"; + + Empty actualResponse = client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchCreateEntitiesRequest actualRequest = (BatchCreateEntitiesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, EntityTypeName.parse(actualRequest.getParent())); + Assert.assertEquals(entities, actualRequest.getEntitiesList()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchCreateEntitiesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-412800396"; + + client.batchCreateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void batchUpdateEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockEntityTypes.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + Empty actualResponse = client.batchUpdateEntitiesAsync(parent, entities).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchUpdateEntitiesRequest actualRequest = (BatchUpdateEntitiesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, EntityTypeName.parse(actualRequest.getParent())); + Assert.assertEquals(entities, actualRequest.getEntitiesList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchUpdateEntitiesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + + client.batchUpdateEntitiesAsync(parent, entities).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void batchUpdateEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchUpdateEntitiesTest2") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockEntityTypes.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-412800396"; + + Empty actualResponse = client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchUpdateEntitiesRequest actualRequest = (BatchUpdateEntitiesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, EntityTypeName.parse(actualRequest.getParent())); + Assert.assertEquals(entities, actualRequest.getEntitiesList()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchUpdateEntitiesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entities = new ArrayList<>(); + String languageCode = "languageCode-412800396"; + + client.batchUpdateEntitiesAsync(parent, entities, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void batchDeleteEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockEntityTypes.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + + Empty actualResponse = client.batchDeleteEntitiesAsync(parent, entityValues).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchDeleteEntitiesRequest actualRequest = (BatchDeleteEntitiesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, EntityTypeName.parse(actualRequest.getParent())); + Assert.assertEquals(entityValues, actualRequest.getEntityValuesList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchDeleteEntitiesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + + client.batchDeleteEntitiesAsync(parent, entityValues).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + @SuppressWarnings("all") + public void batchDeleteEntitiesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteEntitiesTest2") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockEntityTypes.addResponse(resultOperation); + + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-412800396"; + + Empty actualResponse = + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchDeleteEntitiesRequest actualRequest = (BatchDeleteEntitiesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, EntityTypeName.parse(actualRequest.getParent())); + Assert.assertEquals(entityValues, actualRequest.getEntityValuesList()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchDeleteEntitiesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockEntityTypes.addException(exception); + + try { + EntityTypeName parent = EntityTypeName.of("[PROJECT]", "[ENTITY_TYPE]"); + List entityValues = new ArrayList<>(); + String languageCode = "languageCode-412800396"; + + client.batchDeleteEntitiesAsync(parent, entityValues, languageCode).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientTest.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientTest.java new file mode 100644 index 000000000000..4dcb52ac883d --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/IntentsClientTest.java @@ -0,0 +1,656 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.IntentsClient.ListIntentsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class IntentsClientTest { + private static MockAgents mockAgents; + private static MockContexts mockContexts; + private static MockEntityTypes mockEntityTypes; + private static MockIntents mockIntents; + private static MockSessionEntityTypes mockSessionEntityTypes; + private static MockSessions mockSessions; + private static MockServiceHelper serviceHelper; + private IntentsClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockAgents = new MockAgents(); + mockContexts = new MockContexts(); + mockEntityTypes = new MockEntityTypes(); + mockIntents = new MockIntents(); + mockSessionEntityTypes = new MockSessionEntityTypes(); + mockSessions = new MockSessions(); + serviceHelper = + new MockServiceHelper( + "in-process-1", + Arrays.asList( + mockAgents, + mockContexts, + mockEntityTypes, + mockIntents, + mockSessionEntityTypes, + mockSessions)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + IntentsSettings settings = + IntentsSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = IntentsClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void listIntentsTest() { + String nextPageToken = ""; + Intent intentsElement = Intent.newBuilder().build(); + List intents = Arrays.asList(intentsElement); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllIntents(intents) + .build(); + mockIntents.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + + ListIntentsPagedResponse pagedListResponse = client.listIntents(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getIntentsList().get(0), resources.get(0)); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListIntentsRequest actualRequest = (ListIntentsRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listIntentsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + + client.listIntents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listIntentsTest2() { + String nextPageToken = ""; + Intent intentsElement = Intent.newBuilder().build(); + List intents = Arrays.asList(intentsElement); + ListIntentsResponse expectedResponse = + ListIntentsResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllIntents(intents) + .build(); + mockIntents.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + String languageCode = "languageCode-412800396"; + + ListIntentsPagedResponse pagedListResponse = client.listIntents(parent, languageCode); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getIntentsList().get(0), resources.get(0)); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListIntentsRequest actualRequest = (ListIntentsRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listIntentsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + String languageCode = "languageCode-412800396"; + + client.listIntents(parent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getIntentTest() { + IntentName name2 = IntentName.of("[PROJECT]", "[INTENT]"); + String displayName = "displayName1615086568"; + int priority = 1165461084; + boolean isFallback = false; + boolean mlDisabled = true; + String action = "action-1422950858"; + boolean resetContexts = true; + String rootFollowupIntentName = "rootFollowupIntentName402253784"; + String parentFollowupIntentName = "parentFollowupIntentName-1131901680"; + Intent expectedResponse = + Intent.newBuilder() + .setName(name2.toString()) + .setDisplayName(displayName) + .setPriority(priority) + .setIsFallback(isFallback) + .setMlDisabled(mlDisabled) + .setAction(action) + .setResetContexts(resetContexts) + .setRootFollowupIntentName(rootFollowupIntentName) + .setParentFollowupIntentName(parentFollowupIntentName) + .build(); + mockIntents.addResponse(expectedResponse); + + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + + Intent actualResponse = client.getIntent(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetIntentRequest actualRequest = (GetIntentRequest) actualRequests.get(0); + + Assert.assertEquals(name, IntentName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getIntentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + + client.getIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getIntentTest2() { + IntentName name2 = IntentName.of("[PROJECT]", "[INTENT]"); + String displayName = "displayName1615086568"; + int priority = 1165461084; + boolean isFallback = false; + boolean mlDisabled = true; + String action = "action-1422950858"; + boolean resetContexts = true; + String rootFollowupIntentName = "rootFollowupIntentName402253784"; + String parentFollowupIntentName = "parentFollowupIntentName-1131901680"; + Intent expectedResponse = + Intent.newBuilder() + .setName(name2.toString()) + .setDisplayName(displayName) + .setPriority(priority) + .setIsFallback(isFallback) + .setMlDisabled(mlDisabled) + .setAction(action) + .setResetContexts(resetContexts) + .setRootFollowupIntentName(rootFollowupIntentName) + .setParentFollowupIntentName(parentFollowupIntentName) + .build(); + mockIntents.addResponse(expectedResponse); + + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-412800396"; + + Intent actualResponse = client.getIntent(name, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetIntentRequest actualRequest = (GetIntentRequest) actualRequests.get(0); + + Assert.assertEquals(name, IntentName.parse(actualRequest.getName())); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getIntentExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + String languageCode = "languageCode-412800396"; + + client.getIntent(name, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createIntentTest() { + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + String displayName = "displayName1615086568"; + int priority = 1165461084; + boolean isFallback = false; + boolean mlDisabled = true; + String action = "action-1422950858"; + boolean resetContexts = true; + String rootFollowupIntentName = "rootFollowupIntentName402253784"; + String parentFollowupIntentName = "parentFollowupIntentName-1131901680"; + Intent expectedResponse = + Intent.newBuilder() + .setName(name.toString()) + .setDisplayName(displayName) + .setPriority(priority) + .setIsFallback(isFallback) + .setMlDisabled(mlDisabled) + .setAction(action) + .setResetContexts(resetContexts) + .setRootFollowupIntentName(rootFollowupIntentName) + .setParentFollowupIntentName(parentFollowupIntentName) + .build(); + mockIntents.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + + Intent actualResponse = client.createIntent(parent, intent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateIntentRequest actualRequest = (CreateIntentRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(intent, actualRequest.getIntent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createIntentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + + client.createIntent(parent, intent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createIntentTest2() { + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + String displayName = "displayName1615086568"; + int priority = 1165461084; + boolean isFallback = false; + boolean mlDisabled = true; + String action = "action-1422950858"; + boolean resetContexts = true; + String rootFollowupIntentName = "rootFollowupIntentName402253784"; + String parentFollowupIntentName = "parentFollowupIntentName-1131901680"; + Intent expectedResponse = + Intent.newBuilder() + .setName(name.toString()) + .setDisplayName(displayName) + .setPriority(priority) + .setIsFallback(isFallback) + .setMlDisabled(mlDisabled) + .setAction(action) + .setResetContexts(resetContexts) + .setRootFollowupIntentName(rootFollowupIntentName) + .setParentFollowupIntentName(parentFollowupIntentName) + .build(); + mockIntents.addResponse(expectedResponse); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + Intent actualResponse = client.createIntent(parent, intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateIntentRequest actualRequest = (CreateIntentRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(intent, actualRequest.getIntent()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createIntentExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + client.createIntent(parent, intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateIntentTest() { + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + String displayName = "displayName1615086568"; + int priority = 1165461084; + boolean isFallback = false; + boolean mlDisabled = true; + String action = "action-1422950858"; + boolean resetContexts = true; + String rootFollowupIntentName = "rootFollowupIntentName402253784"; + String parentFollowupIntentName = "parentFollowupIntentName-1131901680"; + Intent expectedResponse = + Intent.newBuilder() + .setName(name.toString()) + .setDisplayName(displayName) + .setPriority(priority) + .setIsFallback(isFallback) + .setMlDisabled(mlDisabled) + .setAction(action) + .setResetContexts(resetContexts) + .setRootFollowupIntentName(rootFollowupIntentName) + .setParentFollowupIntentName(parentFollowupIntentName) + .build(); + mockIntents.addResponse(expectedResponse); + + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + Intent actualResponse = client.updateIntent(intent, languageCode); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateIntentRequest actualRequest = (UpdateIntentRequest) actualRequests.get(0); + + Assert.assertEquals(intent, actualRequest.getIntent()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void updateIntentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-412800396"; + + client.updateIntent(intent, languageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateIntentTest2() { + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + String displayName = "displayName1615086568"; + int priority = 1165461084; + boolean isFallback = false; + boolean mlDisabled = true; + String action = "action-1422950858"; + boolean resetContexts = true; + String rootFollowupIntentName = "rootFollowupIntentName402253784"; + String parentFollowupIntentName = "parentFollowupIntentName-1131901680"; + Intent expectedResponse = + Intent.newBuilder() + .setName(name.toString()) + .setDisplayName(displayName) + .setPriority(priority) + .setIsFallback(isFallback) + .setMlDisabled(mlDisabled) + .setAction(action) + .setResetContexts(resetContexts) + .setRootFollowupIntentName(rootFollowupIntentName) + .setParentFollowupIntentName(parentFollowupIntentName) + .build(); + mockIntents.addResponse(expectedResponse); + + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-412800396"; + FieldMask updateMask = FieldMask.newBuilder().build(); + + Intent actualResponse = client.updateIntent(intent, languageCode, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateIntentRequest actualRequest = (UpdateIntentRequest) actualRequests.get(0); + + Assert.assertEquals(intent, actualRequest.getIntent()); + Assert.assertEquals(languageCode, actualRequest.getLanguageCode()); + Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void updateIntentExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + Intent intent = Intent.newBuilder().build(); + String languageCode = "languageCode-412800396"; + FieldMask updateMask = FieldMask.newBuilder().build(); + + client.updateIntent(intent, languageCode, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteIntentTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockIntents.addResponse(expectedResponse); + + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + + client.deleteIntent(name); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteIntentRequest actualRequest = (DeleteIntentRequest) actualRequests.get(0); + + Assert.assertEquals(name, IntentName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteIntentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + IntentName name = IntentName.of("[PROJECT]", "[INTENT]"); + + client.deleteIntent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void batchDeleteIntentsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchDeleteIntentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockIntents.addResponse(resultOperation); + + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + List intents = new ArrayList<>(); + + Empty actualResponse = client.batchDeleteIntentsAsync(parent, intents).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIntents.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BatchDeleteIntentsRequest actualRequest = (BatchDeleteIntentsRequest) actualRequests.get(0); + + Assert.assertEquals(parent, ProjectAgentName.parse(actualRequest.getParent())); + Assert.assertEquals(intents, actualRequest.getIntentsList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void batchDeleteIntentsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockIntents.addException(exception); + + try { + ProjectAgentName parent = ProjectAgentName.of("[PROJECT]"); + List intents = new ArrayList<>(); + + client.batchDeleteIntentsAsync(parent, intents).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgents.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgents.java new file mode 100644 index 000000000000..6deff00d85f9 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgents.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.ServerServiceDefinition; +import java.util.List; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockAgents implements MockGrpcService { + private final MockAgentsImpl serviceImpl; + + public MockAgents() { + serviceImpl = new MockAgentsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(GeneratedMessageV3 response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgentsImpl.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgentsImpl.java new file mode 100644 index 000000000000..3e198ed818ce --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockAgentsImpl.java @@ -0,0 +1,145 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.cloud.dialogflow.v2.AgentsGrpc.AgentsImplBase; +import com.google.longrunning.Operation; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockAgentsImpl extends AgentsImplBase { + private ArrayList requests; + private Queue responses; + + public MockAgentsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(GeneratedMessageV3 response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void getAgent(GetAgentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Agent) { + requests.add(request); + responseObserver.onNext((Agent) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void searchAgents( + SearchAgentsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof SearchAgentsResponse) { + requests.add(request); + responseObserver.onNext((SearchAgentsResponse) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void trainAgent(TrainAgentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void exportAgent(ExportAgentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void importAgent(ImportAgentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void restoreAgent( + RestoreAgentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContexts.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContexts.java new file mode 100644 index 000000000000..56b507d1872a --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContexts.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.ServerServiceDefinition; +import java.util.List; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockContexts implements MockGrpcService { + private final MockContextsImpl serviceImpl; + + public MockContexts() { + serviceImpl = new MockContextsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(GeneratedMessageV3 response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContextsImpl.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContextsImpl.java new file mode 100644 index 000000000000..41c490d98225 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockContextsImpl.java @@ -0,0 +1,147 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.cloud.dialogflow.v2.ContextsGrpc.ContextsImplBase; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockContextsImpl extends ContextsImplBase { + private ArrayList requests; + private Queue responses; + + public MockContextsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(GeneratedMessageV3 response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listContexts( + ListContextsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListContextsResponse) { + requests.add(request); + responseObserver.onNext((ListContextsResponse) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void getContext(GetContextRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Context) { + requests.add(request); + responseObserver.onNext((Context) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void createContext( + CreateContextRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Context) { + requests.add(request); + responseObserver.onNext((Context) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void updateContext( + UpdateContextRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Context) { + requests.add(request); + responseObserver.onNext((Context) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void deleteContext(DeleteContextRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext((Empty) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void deleteAllContexts( + DeleteAllContextsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext((Empty) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypes.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypes.java new file mode 100644 index 000000000000..82d5615eac0c --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypes.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.ServerServiceDefinition; +import java.util.List; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockEntityTypes implements MockGrpcService { + private final MockEntityTypesImpl serviceImpl; + + public MockEntityTypes() { + serviceImpl = new MockEntityTypesImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(GeneratedMessageV3 response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypesImpl.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypesImpl.java new file mode 100644 index 000000000000..24b682822619 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockEntityTypesImpl.java @@ -0,0 +1,210 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.cloud.dialogflow.v2.EntityTypesGrpc.EntityTypesImplBase; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockEntityTypesImpl extends EntityTypesImplBase { + private ArrayList requests; + private Queue responses; + + public MockEntityTypesImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(GeneratedMessageV3 response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listEntityTypes( + ListEntityTypesRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListEntityTypesResponse) { + requests.add(request); + responseObserver.onNext((ListEntityTypesResponse) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void getEntityType( + GetEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof EntityType) { + requests.add(request); + responseObserver.onNext((EntityType) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void createEntityType( + CreateEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof EntityType) { + requests.add(request); + responseObserver.onNext((EntityType) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void updateEntityType( + UpdateEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof EntityType) { + requests.add(request); + responseObserver.onNext((EntityType) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void deleteEntityType( + DeleteEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext((Empty) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void batchUpdateEntityTypes( + BatchUpdateEntityTypesRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void batchDeleteEntityTypes( + BatchDeleteEntityTypesRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void batchCreateEntities( + BatchCreateEntitiesRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void batchUpdateEntities( + BatchUpdateEntitiesRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void batchDeleteEntities( + BatchDeleteEntitiesRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntents.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntents.java new file mode 100644 index 000000000000..8067ac76129c --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntents.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.ServerServiceDefinition; +import java.util.List; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockIntents implements MockGrpcService { + private final MockIntentsImpl serviceImpl; + + public MockIntents() { + serviceImpl = new MockIntentsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(GeneratedMessageV3 response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntentsImpl.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntentsImpl.java new file mode 100644 index 000000000000..3c50682bc4ef --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockIntentsImpl.java @@ -0,0 +1,161 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.cloud.dialogflow.v2.IntentsGrpc.IntentsImplBase; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockIntentsImpl extends IntentsImplBase { + private ArrayList requests; + private Queue responses; + + public MockIntentsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(GeneratedMessageV3 response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listIntents( + ListIntentsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListIntentsResponse) { + requests.add(request); + responseObserver.onNext((ListIntentsResponse) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void getIntent(GetIntentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Intent) { + requests.add(request); + responseObserver.onNext((Intent) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void createIntent(CreateIntentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Intent) { + requests.add(request); + responseObserver.onNext((Intent) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void updateIntent(UpdateIntentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Intent) { + requests.add(request); + responseObserver.onNext((Intent) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void deleteIntent(DeleteIntentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext((Empty) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void batchUpdateIntents( + BatchUpdateIntentsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void batchDeleteIntents( + BatchDeleteIntentsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext((Operation) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypes.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypes.java new file mode 100644 index 000000000000..9c766167c8bc --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypes.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.ServerServiceDefinition; +import java.util.List; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockSessionEntityTypes implements MockGrpcService { + private final MockSessionEntityTypesImpl serviceImpl; + + public MockSessionEntityTypes() { + serviceImpl = new MockSessionEntityTypesImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(GeneratedMessageV3 response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypesImpl.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypesImpl.java new file mode 100644 index 000000000000..ad3b60a26438 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionEntityTypesImpl.java @@ -0,0 +1,135 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.cloud.dialogflow.v2.SessionEntityTypesGrpc.SessionEntityTypesImplBase; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockSessionEntityTypesImpl extends SessionEntityTypesImplBase { + private ArrayList requests; + private Queue responses; + + public MockSessionEntityTypesImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(GeneratedMessageV3 response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listSessionEntityTypes( + ListSessionEntityTypesRequest request, + StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListSessionEntityTypesResponse) { + requests.add(request); + responseObserver.onNext((ListSessionEntityTypesResponse) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void getSessionEntityType( + GetSessionEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof SessionEntityType) { + requests.add(request); + responseObserver.onNext((SessionEntityType) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void createSessionEntityType( + CreateSessionEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof SessionEntityType) { + requests.add(request); + responseObserver.onNext((SessionEntityType) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void updateSessionEntityType( + UpdateSessionEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof SessionEntityType) { + requests.add(request); + responseObserver.onNext((SessionEntityType) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void deleteSessionEntityType( + DeleteSessionEntityTypeRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext((Empty) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessions.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessions.java new file mode 100644 index 000000000000..d643b74640a3 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessions.java @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.ServerServiceDefinition; +import java.util.List; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockSessions implements MockGrpcService { + private final MockSessionsImpl serviceImpl; + + public MockSessions() { + serviceImpl = new MockSessionsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(GeneratedMessageV3 response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionsImpl.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionsImpl.java new file mode 100644 index 000000000000..345a96250409 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/MockSessionsImpl.java @@ -0,0 +1,103 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.core.BetaApi; +import com.google.cloud.dialogflow.v2.SessionsGrpc.SessionsImplBase; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + +@javax.annotation.Generated("by GAPIC") +@BetaApi +public class MockSessionsImpl extends SessionsImplBase { + private ArrayList requests; + private Queue responses; + + public MockSessionsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(GeneratedMessageV3 response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void detectIntent( + DetectIntentRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof DetectIntentResponse) { + requests.add(request); + responseObserver.onNext((DetectIntentResponse) response); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public StreamObserver streamingDetectIntent( + final StreamObserver responseObserver) { + final Object response = responses.remove(); + StreamObserver requestObserver = + new StreamObserver() { + @Override + public void onNext(StreamingDetectIntentRequest value) { + if (response instanceof StreamingDetectIntentResponse) { + responseObserver.onNext((StreamingDetectIntentResponse) response); + } else if (response instanceof Exception) { + responseObserver.onError((Exception) response); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void onError(Throwable t) { + responseObserver.onError(t); + } + + @Override + public void onCompleted() { + responseObserver.onCompleted(); + } + }; + return requestObserver; + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientTest.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientTest.java new file mode 100644 index 000000000000..729c4d5b1aa2 --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionEntityTypesClientTest.java @@ -0,0 +1,315 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import static com.google.cloud.dialogflow.v2.SessionEntityTypesClient.ListSessionEntityTypesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class SessionEntityTypesClientTest { + private static MockAgents mockAgents; + private static MockContexts mockContexts; + private static MockEntityTypes mockEntityTypes; + private static MockIntents mockIntents; + private static MockSessionEntityTypes mockSessionEntityTypes; + private static MockSessions mockSessions; + private static MockServiceHelper serviceHelper; + private SessionEntityTypesClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockAgents = new MockAgents(); + mockContexts = new MockContexts(); + mockEntityTypes = new MockEntityTypes(); + mockIntents = new MockIntents(); + mockSessionEntityTypes = new MockSessionEntityTypes(); + mockSessions = new MockSessions(); + serviceHelper = + new MockServiceHelper( + "in-process-1", + Arrays.asList( + mockAgents, + mockContexts, + mockEntityTypes, + mockIntents, + mockSessionEntityTypes, + mockSessions)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + SessionEntityTypesSettings settings = + SessionEntityTypesSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SessionEntityTypesClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void listSessionEntityTypesTest() { + String nextPageToken = ""; + SessionEntityType sessionEntityTypesElement = SessionEntityType.newBuilder().build(); + List sessionEntityTypes = Arrays.asList(sessionEntityTypesElement); + ListSessionEntityTypesResponse expectedResponse = + ListSessionEntityTypesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllSessionEntityTypes(sessionEntityTypes) + .build(); + mockSessionEntityTypes.addResponse(expectedResponse); + + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + + ListSessionEntityTypesPagedResponse pagedListResponse = client.listSessionEntityTypes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSessionEntityTypesList().get(0), resources.get(0)); + + List actualRequests = mockSessionEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListSessionEntityTypesRequest actualRequest = + (ListSessionEntityTypesRequest) actualRequests.get(0); + + Assert.assertEquals(parent, SessionName.parse(actualRequest.getParent())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void listSessionEntityTypesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSessionEntityTypes.addException(exception); + + try { + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + + client.listSessionEntityTypes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getSessionEntityTypeTest() { + SessionEntityTypeName name2 = + SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + SessionEntityType expectedResponse = + SessionEntityType.newBuilder().setName(name2.toString()).build(); + mockSessionEntityTypes.addResponse(expectedResponse); + + SessionEntityTypeName name = + SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + SessionEntityType actualResponse = client.getSessionEntityType(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockSessionEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetSessionEntityTypeRequest actualRequest = (GetSessionEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(name, SessionEntityTypeName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void getSessionEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSessionEntityTypes.addException(exception); + + try { + SessionEntityTypeName name = + SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + client.getSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createSessionEntityTypeTest() { + SessionEntityTypeName name = + SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + SessionEntityType expectedResponse = + SessionEntityType.newBuilder().setName(name.toString()).build(); + mockSessionEntityTypes.addResponse(expectedResponse); + + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + SessionEntityType actualResponse = client.createSessionEntityType(parent, sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockSessionEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateSessionEntityTypeRequest actualRequest = + (CreateSessionEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(parent, SessionName.parse(actualRequest.getParent())); + Assert.assertEquals(sessionEntityType, actualRequest.getSessionEntityType()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void createSessionEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSessionEntityTypes.addException(exception); + + try { + SessionName parent = SessionName.of("[PROJECT]", "[SESSION]"); + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + client.createSessionEntityType(parent, sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateSessionEntityTypeTest() { + SessionEntityTypeName name = + SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + SessionEntityType expectedResponse = + SessionEntityType.newBuilder().setName(name.toString()).build(); + mockSessionEntityTypes.addResponse(expectedResponse); + + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + SessionEntityType actualResponse = client.updateSessionEntityType(sessionEntityType); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockSessionEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateSessionEntityTypeRequest actualRequest = + (UpdateSessionEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(sessionEntityType, actualRequest.getSessionEntityType()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void updateSessionEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSessionEntityTypes.addException(exception); + + try { + SessionEntityType sessionEntityType = SessionEntityType.newBuilder().build(); + + client.updateSessionEntityType(sessionEntityType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteSessionEntityTypeTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockSessionEntityTypes.addResponse(expectedResponse); + + SessionEntityTypeName name = + SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + client.deleteSessionEntityType(name); + + List actualRequests = mockSessionEntityTypes.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteSessionEntityTypeRequest actualRequest = + (DeleteSessionEntityTypeRequest) actualRequests.get(0); + + Assert.assertEquals(name, SessionEntityTypeName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteSessionEntityTypeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSessionEntityTypes.addException(exception); + + try { + SessionEntityTypeName name = + SessionEntityTypeName.of("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"); + + client.deleteSessionEntityType(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } +} diff --git a/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientTest.java b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientTest.java new file mode 100644 index 000000000000..ab321a1e01ee --- /dev/null +++ b/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/SessionsClientTest.java @@ -0,0 +1,202 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.dialogflow.v2; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.grpc.testing.MockStreamObserver; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.protobuf.GeneratedMessageV3; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class SessionsClientTest { + private static MockAgents mockAgents; + private static MockContexts mockContexts; + private static MockEntityTypes mockEntityTypes; + private static MockIntents mockIntents; + private static MockSessionEntityTypes mockSessionEntityTypes; + private static MockSessions mockSessions; + private static MockServiceHelper serviceHelper; + private SessionsClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockAgents = new MockAgents(); + mockContexts = new MockContexts(); + mockEntityTypes = new MockEntityTypes(); + mockIntents = new MockIntents(); + mockSessionEntityTypes = new MockSessionEntityTypes(); + mockSessions = new MockSessions(); + serviceHelper = + new MockServiceHelper( + "in-process-1", + Arrays.asList( + mockAgents, + mockContexts, + mockEntityTypes, + mockIntents, + mockSessionEntityTypes, + mockSessions)); + serviceHelper.start(); + } + + @AfterClass + public static void stopServer() { + serviceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); + SessionsSettings settings = + SessionsSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SessionsClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void detectIntentTest() { + String responseId = "responseId1847552473"; + DetectIntentResponse expectedResponse = + DetectIntentResponse.newBuilder().setResponseId(responseId).build(); + mockSessions.addResponse(expectedResponse); + + SessionName session = SessionName.of("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + + DetectIntentResponse actualResponse = client.detectIntent(session, queryInput); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockSessions.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DetectIntentRequest actualRequest = (DetectIntentRequest) actualRequests.get(0); + + Assert.assertEquals(session, SessionName.parse(actualRequest.getSession())); + Assert.assertEquals(queryInput, actualRequest.getQueryInput()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void detectIntentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSessions.addException(exception); + + try { + SessionName session = SessionName.of("[PROJECT]", "[SESSION]"); + QueryInput queryInput = QueryInput.newBuilder().build(); + + client.detectIntent(session, queryInput); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void streamingDetectIntentTest() throws Exception { + String responseId = "responseId1847552473"; + StreamingDetectIntentResponse expectedResponse = + StreamingDetectIntentResponse.newBuilder().setResponseId(responseId).build(); + mockSessions.addResponse(expectedResponse); + String session = "session1984987798"; + QueryInput queryInput = QueryInput.newBuilder().build(); + StreamingDetectIntentRequest request = + StreamingDetectIntentRequest.newBuilder() + .setSession(session) + .setQueryInput(queryInput) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + BidiStreamingCallable callable = + client.streamingDetectIntentCallable(); + ApiStreamObserver requestObserver = + callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + requestObserver.onCompleted(); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + @SuppressWarnings("all") + public void streamingDetectIntentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockSessions.addException(exception); + String session = "session1984987798"; + QueryInput queryInput = QueryInput.newBuilder().build(); + StreamingDetectIntentRequest request = + StreamingDetectIntentRequest.newBuilder() + .setSession(session) + .setQueryInput(queryInput) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + BidiStreamingCallable callable = + client.streamingDetectIntentCallable(); + ApiStreamObserver requestObserver = + callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } +} diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java index 50a16f16c109..e03509199502 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceClient.java @@ -430,7 +430,7 @@ public final UnaryCallable listInfo // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates an inspect template for re-using frequently used configuration for inspecting content, + * Creates an InspectTemplate for re-using frequently used configuration for inspecting content, * images, and storage. * *

Sample code: @@ -454,7 +454,7 @@ public final InspectTemplate createInspectTemplate(CreateInspectTemplateRequest // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates an inspect template for re-using frequently used configuration for inspecting content, + * Creates an InspectTemplate for re-using frequently used configuration for inspecting content, * images, and storage. * *

Sample code: @@ -478,7 +478,7 @@ public final InspectTemplate createInspectTemplate(CreateInspectTemplateRequest // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Updates the inspect template. + * Updates the InspectTemplate. * *

Sample code: * @@ -501,7 +501,7 @@ public final InspectTemplate updateInspectTemplate(UpdateInspectTemplateRequest // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Updates the inspect template. + * Updates the InspectTemplate. * *

Sample code: * @@ -524,7 +524,7 @@ public final InspectTemplate updateInspectTemplate(UpdateInspectTemplateRequest // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets an inspect template. + * Gets an InspectTemplate. * *

Sample code: * @@ -544,7 +544,7 @@ public final InspectTemplate getInspectTemplate(GetInspectTemplateRequest reques // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets an inspect template. + * Gets an InspectTemplate. * *

Sample code: * @@ -564,7 +564,7 @@ public final InspectTemplate getInspectTemplate(GetInspectTemplateRequest reques // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists inspect templates. + * Lists InspectTemplates. * *

Sample code: * @@ -590,7 +590,7 @@ public final ListInspectTemplatesPagedResponse listInspectTemplates( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists inspect templates. + * Lists InspectTemplates. * *

Sample code: * @@ -615,7 +615,7 @@ public final ListInspectTemplatesPagedResponse listInspectTemplates( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists inspect templates. + * Lists InspectTemplates. * *

Sample code: * @@ -647,7 +647,7 @@ public final ListInspectTemplatesPagedResponse listInspectTemplates( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Deletes an inspect template. + * Deletes an InspectTemplate. * *

Sample code: * @@ -670,7 +670,7 @@ public final void deleteInspectTemplate(DeleteInspectTemplateRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Deletes an inspect template. + * Deletes an InspectTemplate. * *

Sample code: * @@ -692,7 +692,7 @@ public final UnaryCallable deleteInspectTem // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a de-identify template for re-using frequently used configuration for Deidentifying + * Creates a DeidentifyTemplate for re-using frequently used configuration for de-identifying * content, images, and storage. * *

Sample code: @@ -717,7 +717,7 @@ public final DeidentifyTemplate createDeidentifyTemplate( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a de-identify template for re-using frequently used configuration for Deidentifying + * Creates a DeidentifyTemplate for re-using frequently used configuration for de-identifying * content, images, and storage. * *

Sample code: @@ -741,7 +741,7 @@ public final DeidentifyTemplate createDeidentifyTemplate( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Updates the de-identify template. + * Updates the DeidentifyTemplate. * *

Sample code: * @@ -765,7 +765,7 @@ public final DeidentifyTemplate updateDeidentifyTemplate( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Updates the de-identify template. + * Updates the DeidentifyTemplate. * *

Sample code: * @@ -788,7 +788,7 @@ public final DeidentifyTemplate updateDeidentifyTemplate( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets a de-identify template. + * Gets a DeidentifyTemplate. * *

Sample code: * @@ -811,7 +811,7 @@ public final DeidentifyTemplate getDeidentifyTemplate(GetDeidentifyTemplateReque // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets a de-identify template. + * Gets a DeidentifyTemplate. * *

Sample code: * @@ -834,7 +834,7 @@ public final DeidentifyTemplate getDeidentifyTemplate(GetDeidentifyTemplateReque // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists de-identify templates. + * Lists DeidentifyTemplates. * *

Sample code: * @@ -860,7 +860,7 @@ public final ListDeidentifyTemplatesPagedResponse listDeidentifyTemplates( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists de-identify templates. + * Lists DeidentifyTemplates. * *

Sample code: * @@ -885,7 +885,7 @@ public final ListDeidentifyTemplatesPagedResponse listDeidentifyTemplates( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists de-identify templates. + * Lists DeidentifyTemplates. * *

Sample code: * @@ -917,7 +917,7 @@ public final ListDeidentifyTemplatesPagedResponse listDeidentifyTemplates( // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Deletes a de-identify template. + * Deletes a DeidentifyTemplate. * *

Sample code: * @@ -940,7 +940,7 @@ public final void deleteDeidentifyTemplate(DeleteDeidentifyTemplateRequest reque // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Deletes a de-identify template. + * Deletes a DeidentifyTemplate. * *

Sample code: * @@ -963,7 +963,7 @@ public final void deleteDeidentifyTemplate(DeleteDeidentifyTemplateRequest reque // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a new job to inspect storage or calculate risk metrics [How-to + * Creates a new job to inspect storage or calculate risk metrics. [How-to * guide](/dlp/docs/compute-risk-analysis). * *

Sample code: @@ -987,7 +987,7 @@ public final DlpJob createDlpJob(CreateDlpJobRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a new job to inspect storage or calculate risk metrics [How-to + * Creates a new job to inspect storage or calculate risk metrics. [How-to * guide](/dlp/docs/compute-risk-analysis). * *

Sample code: @@ -1493,7 +1493,7 @@ public final UnaryCallable createJobTrigger } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java index 7167697f9b28..477688a2eee1 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/DlpServiceSettings.java @@ -330,6 +330,7 @@ public DlpServiceStubSettings.Builder getStubSettingsBuilder() { return ((DlpServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStub.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStub.java index 6bfe5d967c64..693073547627 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStub.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStub.java @@ -202,4 +202,7 @@ public UnaryCallable updateJobTriggerCallab public UnaryCallable createJobTriggerCallable() { throw new UnsupportedOperationException("Not implemented: createJobTriggerCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java index 72a5bc039c08..fbbf8e66caf7 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/DlpServiceStubSettings.java @@ -1017,6 +1017,7 @@ protected Builder(DlpServiceStubSettings settings) { createJobTriggerSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/GrpcDlpServiceStub.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/GrpcDlpServiceStub.java index 2d1d85bb2038..cf90ef5a3eed 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/GrpcDlpServiceStub.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2/stub/GrpcDlpServiceStub.java @@ -759,7 +759,7 @@ public UnaryCallable createJobTriggerCallab } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceClient.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceClient.java index fdfdb8475bd4..83a1df1ea487 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceClient.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceClient.java @@ -1049,7 +1049,7 @@ private final ListRootCategoriesResponse listRootCategories(ListRootCategoriesRe } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceSettings.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceSettings.java index d93f1eae39b3..fc8e0321e33f 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceSettings.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceSettings.java @@ -221,6 +221,7 @@ public DlpServiceStubSettings.Builder getStubSettingsBuilder() { return ((DlpServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStub.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStub.java index fd0303213439..c955b956d6e7 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStub.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStub.java @@ -103,4 +103,7 @@ public UnaryCallable listInfoTypesC listRootCategoriesCallable() { throw new UnsupportedOperationException("Not implemented: listRootCategoriesCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStubSettings.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStubSettings.java index 22dbfeee6ee7..461740598dad 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStubSettings.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/DlpServiceStubSettings.java @@ -492,6 +492,7 @@ protected Builder(DlpServiceStubSettings settings) { listRootCategoriesSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/GrpcDlpServiceStub.java b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/GrpcDlpServiceStub.java index 88235fe17088..b5c59da53bfd 100644 --- a/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/GrpcDlpServiceStub.java +++ b/google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/GrpcDlpServiceStub.java @@ -342,7 +342,7 @@ public UnaryCallable listInfoTypesC } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceClient.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceClient.java index 678b9df67203..ca828b70db6e 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceClient.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceClient.java @@ -319,7 +319,7 @@ public final UnaryCallable updateGroupCallable() } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceSettings.java index d57dc10e4d7d..10d4c4da7414 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceSettings.java @@ -157,6 +157,7 @@ public ErrorGroupServiceStubSettings.Builder getStubSettingsBuilder() { return ((ErrorGroupServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceClient.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceClient.java index 748105386848..3e9ecc899cf9 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceClient.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceClient.java @@ -573,7 +573,7 @@ public final UnaryCallable deleteEven } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceSettings.java index a41f0beeef00..97b804145e41 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceSettings.java @@ -172,6 +172,7 @@ public ErrorStatsServiceStubSettings.Builder getStubSettingsBuilder() { return ((ErrorStatsServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceClient.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceClient.java index 8d9c3775878f..52f4f6a1e757 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceClient.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceClient.java @@ -288,7 +288,7 @@ public final ReportErrorEventResponse reportErrorEvent(ReportErrorEventRequest r } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceSettings.java index 7dde70553e04..41cdf86ff0f3 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ReportErrorsServiceSettings.java @@ -152,6 +152,7 @@ public ReportErrorsServiceStubSettings.Builder getStubSettingsBuilder() { return ((ReportErrorsServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStub.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStub.java index 33a2c2337b3a..d6358091f250 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStub.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStub.java @@ -40,4 +40,7 @@ public UnaryCallable getGroupCallable() { public UnaryCallable updateGroupCallable() { throw new UnsupportedOperationException("Not implemented: updateGroupCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStubSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStubSettings.java index bb54687561c7..611ef2e0eaa8 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStubSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorGroupServiceStubSettings.java @@ -253,6 +253,7 @@ protected Builder(ErrorGroupServiceStubSettings settings) { ImmutableList.>of(getGroupSettings, updateGroupSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStub.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStub.java index a675b7947346..11cc3aa33da8 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStub.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStub.java @@ -59,4 +59,7 @@ public UnaryCallable listEventsCallable() public UnaryCallable deleteEventsCallable() { throw new UnsupportedOperationException("Not implemented: deleteEventsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStubSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStubSettings.java index 5ab1fd7de5e5..bc6197fdcb8d 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStubSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ErrorStatsServiceStubSettings.java @@ -404,6 +404,7 @@ protected Builder(ErrorStatsServiceStubSettings settings) { listGroupStatsSettings, listEventsSettings, deleteEventsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorGroupServiceStub.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorGroupServiceStub.java index bc9df2be291b..956b302061c3 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorGroupServiceStub.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorGroupServiceStub.java @@ -133,7 +133,7 @@ public UnaryCallable updateGroupCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorStatsServiceStub.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorStatsServiceStub.java index 06e08c61ee48..264f947c6b75 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorStatsServiceStub.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcErrorStatsServiceStub.java @@ -183,7 +183,7 @@ public UnaryCallable deleteEventsCall } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcReportErrorsServiceStub.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcReportErrorsServiceStub.java index cc598ac92801..6cbb249879da 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcReportErrorsServiceStub.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/GrpcReportErrorsServiceStub.java @@ -117,7 +117,7 @@ protected GrpcReportErrorsServiceStub( } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStub.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStub.java index 92b9198fe113..223e4e45c2cb 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStub.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStub.java @@ -36,4 +36,7 @@ public abstract class ReportErrorsServiceStub implements BackgroundResource { reportErrorEventCallable() { throw new UnsupportedOperationException("Not implemented: reportErrorEventCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStubSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStubSettings.java index 344330372bae..d6589458adaf 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStubSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/stub/ReportErrorsServiceStubSettings.java @@ -240,6 +240,7 @@ protected Builder(ReportErrorsServiceStubSettings settings) { ImmutableList.>of(reportErrorEventSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java index 463fcbe9a309..489cf3bbffa2 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java @@ -1152,7 +1152,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreSettings.java index f243c97f5b2e..2bb6d9e03bf3 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreSettings.java @@ -241,6 +241,7 @@ public FirestoreStubSettings.Builder getStubSettingsBuilder() { return ((FirestoreStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStub.java index 49247385cbd4..8854c421ff65 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStub.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStub.java @@ -122,4 +122,7 @@ public BidiStreamingCallable listenCallable() { listCollectionIdsCallable() { throw new UnsupportedOperationException("Not implemented: listCollectionIdsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStubSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStubSettings.java index 7874328df33c..d0f5575cc3fe 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStubSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/FirestoreStubSettings.java @@ -596,6 +596,7 @@ protected Builder(FirestoreStubSettings settings) { listCollectionIdsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/GrpcFirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/GrpcFirestoreStub.java index ef85c46300ca..e67876e378ee 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/GrpcFirestoreStub.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/stub/GrpcFirestoreStub.java @@ -415,7 +415,7 @@ public BidiStreamingCallable listenCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java index 54413bc3aef2..017ed4e78404 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceClient.java @@ -603,7 +603,7 @@ public final UnaryCallable annotateTe } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceSettings.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceSettings.java index 7c855f2cd83f..0ac12effa363 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceSettings.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1/LanguageServiceSettings.java @@ -175,6 +175,7 @@ public LanguageServiceStubSettings.Builder getStubSettingsBuilder() { return ((LanguageServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/GrpcLanguageServiceStub.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/GrpcLanguageServiceStub.java index b8aa0f76a347..c25186ee0957 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/GrpcLanguageServiceStub.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/GrpcLanguageServiceStub.java @@ -244,7 +244,7 @@ public UnaryCallable annotateTextCall } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStub.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStub.java index 43de48f6c82a..cca3d7ff3146 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStub.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStub.java @@ -67,4 +67,7 @@ public UnaryCallable classifyTextCall public UnaryCallable annotateTextCallable() { throw new UnsupportedOperationException("Not implemented: annotateTextCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStubSettings.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStubSettings.java index b279a9e1705d..9ecd63b6bb90 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStubSettings.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1/stub/LanguageServiceStubSettings.java @@ -350,6 +350,7 @@ protected Builder(LanguageServiceStubSettings settings) { annotateTextSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java index 63bac0f1d325..cf9975b0b34b 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceClient.java @@ -604,7 +604,7 @@ public final UnaryCallable annotateTe } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceSettings.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceSettings.java index ab0f59c85084..6fd4e4e7e41c 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceSettings.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/LanguageServiceSettings.java @@ -176,6 +176,7 @@ public LanguageServiceStubSettings.Builder getStubSettingsBuilder() { return ((LanguageServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/GrpcLanguageServiceStub.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/GrpcLanguageServiceStub.java index 7681b65a0332..5e37bf3c241e 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/GrpcLanguageServiceStub.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/GrpcLanguageServiceStub.java @@ -245,7 +245,7 @@ public UnaryCallable annotateTextCall } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStub.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStub.java index d24f8db81f62..1238d452f426 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStub.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStub.java @@ -67,4 +67,7 @@ public UnaryCallable classifyTextCall public UnaryCallable annotateTextCallable() { throw new UnsupportedOperationException("Not implemented: annotateTextCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStubSettings.java b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStubSettings.java index 4f1a991a92e1..b9b37d1d8844 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStubSettings.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/v1beta2/stub/LanguageServiceStubSettings.java @@ -351,6 +351,7 @@ protected Builder(LanguageServiceStubSettings settings) { annotateTextSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigClient.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigClient.java index 799ed494b24f..3f8cd29935f5 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigClient.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigClient.java @@ -1346,7 +1346,7 @@ public final UnaryCallable deleteExclusionCallabl } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigSettings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigSettings.java index 4cdc24d28b25..32440e215ae1 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigSettings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/ConfigSettings.java @@ -214,6 +214,7 @@ public ConfigServiceV2StubSettings.Builder getStubSettingsBuilder() { return ((ConfigServiceV2StubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingClient.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingClient.java index bc3170a7a7ff..3a2ba0dcf2fd 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingClient.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingClient.java @@ -811,7 +811,7 @@ public final UnaryCallable listLogsCallable() } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingSettings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingSettings.java index a547c2525a4d..1da060f0bdc0 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingSettings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/LoggingSettings.java @@ -191,6 +191,7 @@ public LoggingServiceV2StubSettings.Builder getStubSettingsBuilder() { return ((LoggingServiceV2StubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsClient.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsClient.java index 7ed3b8bad7bc..755cfc96fe76 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsClient.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsClient.java @@ -700,7 +700,7 @@ public final UnaryCallable deleteLogMetricCallabl } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsSettings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsSettings.java index c8d72d51d5e7..239e3c16797c 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsSettings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/MetricsSettings.java @@ -180,6 +180,7 @@ public MetricsServiceV2StubSettings.Builder getStubSettingsBuilder() { return ((MetricsServiceV2StubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2Stub.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2Stub.java index a1a0c4788b5a..5438cc4c4bbc 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2Stub.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2Stub.java @@ -96,4 +96,7 @@ public UnaryCallable updateExclusionCallab public UnaryCallable deleteExclusionCallable() { throw new UnsupportedOperationException("Not implemented: deleteExclusionCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java index 872ab54f9731..923b68c47a16 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java @@ -557,6 +557,7 @@ protected Builder(ConfigServiceV2StubSettings settings) { deleteExclusionSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java index 2a3d96ee0644..ffb636b648c1 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java @@ -327,7 +327,7 @@ public UnaryCallable deleteExclusionCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java index 3af51d94e7d6..5feda12ee0ae 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java @@ -259,7 +259,7 @@ public UnaryCallable listLogsCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java index 8101974b9d36..a8209eb07a7e 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java @@ -215,7 +215,7 @@ public UnaryCallable deleteLogMetricCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2Stub.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2Stub.java index bdf7210ea6fa..da38fdfec0b8 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2Stub.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2Stub.java @@ -82,4 +82,7 @@ public UnaryCallable listLogsPagedCallab public UnaryCallable listLogsCallable() { throw new UnsupportedOperationException("Not implemented: listLogsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java index 9f165f9224d9..dd6e02189949 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java @@ -637,6 +637,7 @@ protected Builder(LoggingServiceV2StubSettings settings) { listLogsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2Stub.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2Stub.java index 2de0fd7c545d..e13fab6b065e 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2Stub.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2Stub.java @@ -64,4 +64,7 @@ public UnaryCallable updateLogMetricCallable( public UnaryCallable deleteLogMetricCallable() { throw new UnsupportedOperationException("Not implemented: deleteLogMetricCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java index e1049f1ef1be..a6f33f7d1733 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java @@ -392,6 +392,7 @@ protected Builder(MetricsServiceV2StubSettings settings) { deleteLogMetricSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index 8e6fb35113c6..25a3a439130b 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -710,7 +710,7 @@ public final UnaryCallable updateAlertPol } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java index 21f56fb6eea7..d09a6e91bc64 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java @@ -181,6 +181,7 @@ public AlertPolicyServiceStubSettings.Builder getStubSettingsBuilder() { return ((AlertPolicyServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index 1cd3d56bc294..d22eb3c6526c 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -742,7 +742,7 @@ public final ListGroupMembersPagedResponse listGroupMembers(ListGroupMembersRequ } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java index 86b4a4e9040a..81d959e4ded3 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java @@ -190,6 +190,7 @@ public GroupServiceStubSettings.Builder getStubSettingsBuilder() { return ((GroupServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 7a295b698d8c..8aefd3f1696e 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -1184,7 +1184,7 @@ public final UnaryCallable createTimeSeriesCalla } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java index 6e69ced8d8d0..8b030975575d 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java @@ -214,6 +214,7 @@ public MetricServiceStubSettings.Builder getStubSettingsBuilder() { return ((MetricServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index 6a32390be5d7..a0910ba27ab0 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -987,7 +987,7 @@ public final void deleteNotificationChannel(DeleteNotificationChannelRequest req } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java index 77ab4b0d8f25..bde9592e4710 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java @@ -214,6 +214,7 @@ public NotificationChannelServiceStubSettings.Builder getStubSettingsBuilder() { return ((NotificationChannelServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java index 350a72c51aab..4780bcefcacb 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java @@ -662,7 +662,7 @@ public final ListUptimeCheckIpsPagedResponse listUptimeCheckIps( } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java index a02cc3768fb2..106bb267b490 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java @@ -196,6 +196,7 @@ public UptimeCheckServiceStubSettings.Builder getStubSettingsBuilder() { return ((UptimeCheckServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java index 11aff602cbab..75d3dfa49dd7 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java @@ -65,4 +65,7 @@ public UnaryCallable deleteAlertPolicyCallable( public UnaryCallable updateAlertPolicyCallable() { throw new UnsupportedOperationException("Not implemented: updateAlertPolicyCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java index 7f7e9599ca4f..7207cfe6f4f1 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java @@ -398,6 +398,7 @@ protected Builder(AlertPolicyServiceStubSettings settings) { updateAlertPolicySettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java index f78e1e7881f2..e921b2a0cf03 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java @@ -76,4 +76,7 @@ public UnaryCallable deleteGroupCallable() { listGroupMembersCallable() { throw new UnsupportedOperationException("Not implemented: listGroupMembersCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java index e6877dcc6d40..451127d46c46 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java @@ -469,6 +469,7 @@ protected Builder(GroupServiceStubSettings settings) { listGroupMembersSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java index f1e754413a99..94f0ba117d89 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java @@ -228,7 +228,7 @@ public UnaryCallable updateAlertPolicyCal } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java index b654ff471402..95969299c0d7 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java @@ -239,7 +239,7 @@ public UnaryCallable deleteGroupCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java index 47b85d134b3d..8ef5e77906c5 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java @@ -356,7 +356,7 @@ public UnaryCallable createTimeSeriesCallable() } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java index d93c1178ae22..39312862c277 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java @@ -352,7 +352,7 @@ protected GrpcNotificationChannelServiceStub( } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java index 5f8b881f2ac0..5910201fa0ba 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java @@ -286,7 +286,7 @@ public UnaryCallable deleteUptimeCheckCon } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java index ae510def89ec..ca12402b8736 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java @@ -104,4 +104,7 @@ public UnaryCallable listTimeSeri public UnaryCallable createTimeSeriesCallable() { throw new UnsupportedOperationException("Not implemented: createTimeSeriesCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java index 2ea5277faee3..331cdb65874e 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java @@ -625,6 +625,7 @@ protected Builder(MetricServiceStubSettings settings) { createTimeSeriesSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java index d1877e41522b..c20f7121b9c6 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java @@ -96,4 +96,7 @@ public abstract class NotificationChannelServiceStub implements BackgroundResour deleteNotificationChannelCallable() { throw new UnsupportedOperationException("Not implemented: deleteNotificationChannelCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java index b2fa1a19ca8e..fad8a2859b9b 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java @@ -557,6 +557,7 @@ protected Builder(NotificationChannelServiceStubSettings settings) { deleteNotificationChannelSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java index da1307b5755f..eb8e7c35eebe 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java @@ -82,4 +82,7 @@ public UnaryCallable deleteUptimeCheckCon listUptimeCheckIpsCallable() { throw new UnsupportedOperationException("Not implemented: listUptimeCheckIpsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java index 135f93dfdb99..179d2b0ca980 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java @@ -504,6 +504,7 @@ protected Builder(UptimeCheckServiceStubSettings settings) { listUptimeCheckIpsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceClient.java b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceClient.java index 82a679e20e58..fc90fad0bed8 100644 --- a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceClient.java +++ b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceClient.java @@ -891,7 +891,7 @@ public final UnaryCallable updateSshPub } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceSettings.java b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceSettings.java index ccd0f67db49d..be5fb46f9b42 100644 --- a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceSettings.java +++ b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/OsLoginServiceSettings.java @@ -176,6 +176,7 @@ public OsLoginServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsLoginServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/GrpcOsLoginServiceStub.java b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/GrpcOsLoginServiceStub.java index 6c76e516a5dc..bc36069c1037 100644 --- a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/GrpcOsLoginServiceStub.java +++ b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/GrpcOsLoginServiceStub.java @@ -237,7 +237,7 @@ public UnaryCallable updateSshPublicKey } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStub.java b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStub.java index ad76bec1297c..a471245e74fe 100644 --- a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStub.java +++ b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStub.java @@ -64,4 +64,7 @@ public UnaryCallable getSshPublicKeyCallab public UnaryCallable updateSshPublicKeyCallable() { throw new UnsupportedOperationException("Not implemented: updateSshPublicKeyCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStubSettings.java b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStubSettings.java index f192da078b1d..5dcb9876ba95 100644 --- a/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStubSettings.java +++ b/google-cloud-os-login/src/main/java/com/google/cloud/oslogin/v1/stub/OsLoginServiceStubSettings.java @@ -349,6 +349,7 @@ protected Builder(OsLoginServiceStubSettings settings) { updateSshPublicKeySettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java index 2c6fe9137875..99862cd35814 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java @@ -2114,7 +2114,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java index cb08ae52f7c2..0417e8258fc5 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java @@ -271,6 +271,7 @@ public SubscriberStubSettings.Builder getStubSettingsBuilder() { return ((SubscriberStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java index 8b3625fb9c9c..b0322cc6d6f3 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java @@ -1151,7 +1151,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java index a0a766b50360..434a88834afe 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java @@ -218,6 +218,7 @@ public PublisherStubSettings.Builder getStubSettingsBuilder() { return ((PublisherStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java index 3b337b6edafb..729349bab571 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java @@ -335,7 +335,7 @@ public UnaryCallable getIamPolicyCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java index 30db137cc61e..16c1ff1b23f8 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java @@ -531,7 +531,7 @@ public UnaryCallable getIamPolicyCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStub.java index 6b60a1bcee2f..363ac2af59ac 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStub.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStub.java @@ -100,4 +100,7 @@ public UnaryCallable getIamPolicyCallable() { testIamPermissionsCallable() { throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java index b736d918c6d7..b41dd2d2ee3d 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java @@ -667,6 +667,7 @@ protected Builder(PublisherStubSettings settings) { testIamPermissionsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStub.java index 2e87f8246081..c6e0d9790db5 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStub.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStub.java @@ -145,4 +145,7 @@ public UnaryCallable getIamPolicyCallable() { testIamPermissionsCallable() { throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java index aca2c9143111..67ba2045e72e 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java @@ -738,6 +738,7 @@ protected Builder(SubscriberStubSettings settings) { testIamPermissionsSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerClient.java index 33f1c4891609..7aceee45e4d5 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerClient.java @@ -1443,7 +1443,7 @@ public final UnaryCallable partitionRea } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerSettings.java index c8caa2d9c2f4..5bc911ad6db1 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerSettings.java @@ -232,6 +232,7 @@ public SpannerStubSettings.Builder getStubSettingsBuilder() { return ((SpannerStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java index 7b900fddc150..a4abd70ada4f 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java @@ -378,7 +378,7 @@ public UnaryCallable partitionReadCalla } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStub.java index ea064e884913..4a01844e70f9 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStub.java @@ -108,4 +108,7 @@ public UnaryCallable partitionQueryCal public UnaryCallable partitionReadCallable() { throw new UnsupportedOperationException("Not implemented: partitionReadCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java index e7dcf5acafc9..52e00ad456d8 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java @@ -545,6 +545,7 @@ protected Builder(SpannerStubSettings settings) { partitionReadSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java index d65ed9f97e96..2d0dab436c49 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechClient.java @@ -469,7 +469,7 @@ public final UnaryCallable recognizeCallabl } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechSettings.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechSettings.java index 527567dec43f..a40efd0dd743 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechSettings.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/SpeechSettings.java @@ -168,6 +168,7 @@ public SpeechStubSettings.Builder getStubSettingsBuilder() { return ((SpeechStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/GrpcSpeechStub.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/GrpcSpeechStub.java index ad90ab6d1c70..bb01407e976c 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/GrpcSpeechStub.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/GrpcSpeechStub.java @@ -186,7 +186,7 @@ public UnaryCallable longRunningRecogniz } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStub.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStub.java index f7363c7ecc44..7019a26fbb14 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStub.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStub.java @@ -64,4 +64,7 @@ public UnaryCallable longRunningRecogniz streamingRecognizeCallable() { throw new UnsupportedOperationException("Not implemented: streamingRecognizeCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStubSettings.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStubSettings.java index d1c0d7b97bfd..f607abf900a6 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStubSettings.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1/stub/SpeechStubSettings.java @@ -324,6 +324,7 @@ protected Builder(SpeechStubSettings settings) { recognizeSettings, longRunningRecognizeSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechClient.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechClient.java index a04b04132c37..8eb15d4ecef7 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechClient.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechClient.java @@ -457,7 +457,7 @@ public final UnaryCallable asyncRecognizeCalla } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechSettings.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechSettings.java index 456b937eafbc..edd7dd64c1dd 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechSettings.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/SpeechSettings.java @@ -168,6 +168,7 @@ public SpeechStubSettings.Builder getStubSettingsBuilder() { return ((SpeechStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/GrpcSpeechStub.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/GrpcSpeechStub.java index 9c4748c53ee0..e254bb49f06e 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/GrpcSpeechStub.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/GrpcSpeechStub.java @@ -185,7 +185,7 @@ public UnaryCallable asyncRecognizeCallable() } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStub.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStub.java index d74d39055576..6efbfc385309 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStub.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStub.java @@ -62,4 +62,7 @@ public UnaryCallable asyncRecognizeCallable() streamingRecognizeCallable() { throw new UnsupportedOperationException("Not implemented: streamingRecognizeCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStubSettings.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStubSettings.java index 6f393bb761d7..e3bed370decb 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStubSettings.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1beta1/stub/SpeechStubSettings.java @@ -321,6 +321,7 @@ protected Builder(SpeechStubSettings settings) { syncRecognizeSettings, asyncRecognizeSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java index ae09d273143d..a2e05010bcd1 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechClient.java @@ -469,7 +469,7 @@ public final UnaryCallable recognizeCallabl } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechSettings.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechSettings.java index 2c374665b091..ba17df62988d 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechSettings.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/SpeechSettings.java @@ -168,6 +168,7 @@ public SpeechStubSettings.Builder getStubSettingsBuilder() { return ((SpeechStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/GrpcSpeechStub.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/GrpcSpeechStub.java index 29a7398280cc..18bbb3058ff0 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/GrpcSpeechStub.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/GrpcSpeechStub.java @@ -186,7 +186,7 @@ public UnaryCallable longRunningRecogniz } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStub.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStub.java index 18fff8160e23..4d34572f0fdc 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStub.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStub.java @@ -64,4 +64,7 @@ public UnaryCallable longRunningRecogniz streamingRecognizeCallable() { throw new UnsupportedOperationException("Not implemented: streamingRecognizeCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStubSettings.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStubSettings.java index f94301f3bbf0..46ef5ebdef61 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStubSettings.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/SpeechStubSettings.java @@ -324,6 +324,7 @@ protected Builder(SpeechStubSettings settings) { recognizeSettings, longRunningRecognizeSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java index 70c373ea8502..eabdee099b98 100644 --- a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java +++ b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechClient.java @@ -298,7 +298,7 @@ public final SynthesizeSpeechResponse synthesizeSpeech(SynthesizeSpeechRequest r } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java index 0263d198ef33..16a8d492c943 100644 --- a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java +++ b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/TextToSpeechSettings.java @@ -154,6 +154,7 @@ public TextToSpeechStubSettings.Builder getStubSettingsBuilder() { return ((TextToSpeechStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/GrpcTextToSpeechStub.java b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/GrpcTextToSpeechStub.java index 5dee1658c92f..34a8dd0aa0c3 100644 --- a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/GrpcTextToSpeechStub.java +++ b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/GrpcTextToSpeechStub.java @@ -136,7 +136,7 @@ public UnaryCallable listVoicesCallable() } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStub.java b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStub.java index 17107e7b459a..2d4214b676da 100644 --- a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStub.java +++ b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStub.java @@ -42,4 +42,7 @@ public UnaryCallable listVoicesCallable() synthesizeSpeechCallable() { throw new UnsupportedOperationException("Not implemented: synthesizeSpeechCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java index c4b6ccef6a9f..a192ab2ef905 100644 --- a/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java +++ b/google-cloud-texttospeech/src/main/java/com/google/cloud/texttospeech/v1beta1/stub/TextToSpeechStubSettings.java @@ -259,6 +259,7 @@ protected Builder(TextToSpeechStubSettings settings) { listVoicesSettings, synthesizeSpeechSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceClient.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceClient.java index 63ac49c29e76..a099d882f456 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceClient.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceClient.java @@ -423,7 +423,7 @@ public final UnaryCallable listTracesCall } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceSettings.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceSettings.java index c3c5b3e02232..e2cf05ecfde5 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceSettings.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/TraceServiceSettings.java @@ -168,6 +168,7 @@ public TraceServiceStubSettings.Builder getStubSettingsBuilder() { return ((TraceServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/GrpcTraceServiceStub.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/GrpcTraceServiceStub.java index 7e5beb1862bf..552442a2e4ac 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/GrpcTraceServiceStub.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/GrpcTraceServiceStub.java @@ -161,7 +161,7 @@ public UnaryCallable listTracesCallable() } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStub.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStub.java index 92aa4c2a7852..1d9459c9d8b2 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStub.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStub.java @@ -53,4 +53,7 @@ public UnaryCallable listTracesPaged public UnaryCallable listTracesCallable() { throw new UnsupportedOperationException("Not implemented: listTracesCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStubSettings.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStubSettings.java index 1e33c8bf3687..194ce03d1f58 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStubSettings.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v1/stub/TraceServiceStubSettings.java @@ -343,6 +343,7 @@ protected Builder(TraceServiceStubSettings settings) { patchTracesSettings, getTraceSettings, listTracesSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceClient.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceClient.java index 1785c0ea50c8..96458b56ca61 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceClient.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceClient.java @@ -320,7 +320,7 @@ public final UnaryCallable createSpanCallable() { } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceSettings.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceSettings.java index 56f0d660d45b..b9048eeda93e 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceSettings.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/TraceServiceSettings.java @@ -156,6 +156,7 @@ public TraceServiceStubSettings.Builder getStubSettingsBuilder() { return ((TraceServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/GrpcTraceServiceStub.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/GrpcTraceServiceStub.java index d746af77c67b..d3287a7bbeab 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/GrpcTraceServiceStub.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/GrpcTraceServiceStub.java @@ -130,7 +130,7 @@ public UnaryCallable createSpanCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStub.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStub.java index cbb7b06ad328..27b288595c25 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStub.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStub.java @@ -40,4 +40,7 @@ public UnaryCallable batchWriteSpansCallable() { public UnaryCallable createSpanCallable() { throw new UnsupportedOperationException("Not implemented: createSpanCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStubSettings.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStubSettings.java index c58853d9799f..d121b68ad473 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStubSettings.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/v2/stub/TraceServiceStubSettings.java @@ -257,6 +257,7 @@ protected Builder(TraceServiceStubSettings settings) { batchWriteSpansSettings, createSpanSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java index 4ed72db6307d..b623d7d3ab51 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java @@ -290,7 +290,7 @@ public final UnaryCallable annotateVideoCallabl } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java index 525ad55d8814..a1709c2317f8 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java @@ -160,6 +160,7 @@ public VideoIntelligenceServiceStubSettings.Builder getStubSettingsBuilder() { return ((VideoIntelligenceServiceStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/GrpcVideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/GrpcVideoIntelligenceServiceStub.java index 941b56af8e79..50cf22c061bf 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/GrpcVideoIntelligenceServiceStub.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/GrpcVideoIntelligenceServiceStub.java @@ -138,7 +138,7 @@ public UnaryCallable annotateVideoCallable() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java index 0e86413ad8f4..756cc4e71c9b 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java @@ -48,4 +48,7 @@ public OperationsStub getOperationsStub() { public UnaryCallable annotateVideoCallable() { throw new UnsupportedOperationException("Not implemented: annotateVideoCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java index fc1f951a9aec..2dd3a09eaed4 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java @@ -283,6 +283,7 @@ protected Builder(VideoIntelligenceServiceStubSettings settings) { ImmutableList.>of(annotateVideoSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java index 2530276ea9e1..28b9228f21b6 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorClient.java @@ -218,7 +218,7 @@ private final BatchAnnotateImagesResponse batchAnnotateImages( } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java index 40f8fd501a3a..c067becbe892 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/ImageAnnotatorSettings.java @@ -148,6 +148,7 @@ public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/GrpcImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/GrpcImageAnnotatorStub.java index 9e464d77f9cd..3a87b380db73 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/GrpcImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/GrpcImageAnnotatorStub.java @@ -118,7 +118,7 @@ protected GrpcImageAnnotatorStub( } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java index 41767d14bf36..8c17b9fbbe7a 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStub.java @@ -36,4 +36,7 @@ public abstract class ImageAnnotatorStub implements BackgroundResource { batchAnnotateImagesCallable() { throw new UnsupportedOperationException("Not implemented: batchAnnotateImagesCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java index 56cb49c63867..ac653212f05d 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1/stub/ImageAnnotatorStubSettings.java @@ -240,6 +240,7 @@ protected Builder(ImageAnnotatorStubSettings settings) { ImmutableList.>of(batchAnnotateImagesSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java index 727ae9066d7f..0a910c69416b 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorClient.java @@ -219,7 +219,7 @@ private final BatchAnnotateImagesResponse batchAnnotateImages( } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java index cf57682cb3b1..bb4a622f11e2 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/ImageAnnotatorSettings.java @@ -149,6 +149,7 @@ public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/GrpcImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/GrpcImageAnnotatorStub.java index 7951d9f1b995..be45bbf7b848 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/GrpcImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/GrpcImageAnnotatorStub.java @@ -118,7 +118,7 @@ protected GrpcImageAnnotatorStub( } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStub.java index 715fe9491887..c99a0047b05b 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStub.java @@ -36,4 +36,7 @@ public abstract class ImageAnnotatorStub implements BackgroundResource { batchAnnotateImagesCallable() { throw new UnsupportedOperationException("Not implemented: batchAnnotateImagesCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java index 2c8db1bd7476..1678eb414e65 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p1beta1/stub/ImageAnnotatorStubSettings.java @@ -241,6 +241,7 @@ protected Builder(ImageAnnotatorStubSettings settings) { ImmutableList.>of(batchAnnotateImagesSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorClient.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorClient.java index 0ccf242c109f..92f0c495577d 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorClient.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorClient.java @@ -344,7 +344,7 @@ private final BatchAnnotateImagesResponse batchAnnotateImages( } @Override - public final void close() throws Exception { + public final void close() { stub.close(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java index 3e5b601c6147..6e26aa01ee0f 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/ImageAnnotatorSettings.java @@ -164,6 +164,7 @@ public ImageAnnotatorStubSettings.Builder getStubSettingsBuilder() { return ((ImageAnnotatorStubSettings.Builder) getStubSettings()); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/GrpcImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/GrpcImageAnnotatorStub.java index c9fbd3278b4b..82b995d847c8 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/GrpcImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/GrpcImageAnnotatorStub.java @@ -172,7 +172,7 @@ public GrpcOperationsStub getOperationsStub() { } @Override - public final void close() throws Exception { + public final void close() { shutdown(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java index c7d036f4a91e..55d7192e5097 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStub.java @@ -58,4 +58,7 @@ public OperationsStub getOperationsStub() { asyncBatchAnnotateFilesCallable() { throw new UnsupportedOperationException("Not implemented: asyncBatchAnnotateFilesCallable()"); } + + @Override + public abstract void close(); } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java index 3fd3039e79b5..02d3627798ac 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/v1p2beta1/stub/ImageAnnotatorStubSettings.java @@ -312,6 +312,7 @@ protected Builder(ImageAnnotatorStubSettings settings) { batchAnnotateImagesSettings, asyncBatchAnnotateFilesSettings); } + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/pom.xml b/pom.xml index b3e91973143b..54cd383c85c9 100644 --- a/pom.xml +++ b/pom.xml @@ -741,7 +741,7 @@ Stub packages - com.google.cloud.bigquerydatatransfer.v1.stub:com.google.cloud.container.v1.stub:com.google.cloud.dlp.v2beta1.stub:com.google.cloud.dlp.v2.stub:com.google.cloud.dialogflow.v2beta1.stub:com.google.cloud.errorreporting.v1beta1.stub:com.google.cloud.firestore.v1beta1.stub:com.google.cloud.language.v1beta2.stub:com.google.cloud.language.v1.stub:com.google.cloud.logging.v2.stub:com.google.cloud.monitoring.v3.stub:com.google.cloud.pubsub.v1.stub:com.google.cloud.speech.v1beta1.stub:com.google.cloud.speech.v1.stub:com.google.cloud.texttospeech.v1beta1.stub:com.google.cloud.trace.v1.stub:com.google.cloud.trace.v2.stub:com.google.cloud.videointelligence.v1beta1.stub:com.google.cloud.videointelligence.v1beta2.stub:com.google.cloud.videointelligence.v1.stub:com.google.cloud.videointelligence.v1p1beta1.stub:com.google.cloud.vision.v1.stub:com.google.cloud.vision.v1p1beta1.stub:com.google.cloud.vision.v1p2beta1.stub + com.google.cloud.bigquerydatatransfer.v1.stub:com.google.cloud.container.v1.stub:com.google.cloud.dlp.v2beta1.stub:com.google.cloud.dlp.v2.stub:com.google.cloud.dialogflow.v2beta1.stub:com.google.cloud.dialogflow.v2.stub:com.google.cloud.errorreporting.v1beta1.stub:com.google.cloud.firestore.v1beta1.stub:com.google.cloud.language.v1beta2.stub:com.google.cloud.language.v1.stub:com.google.cloud.logging.v2.stub:com.google.cloud.monitoring.v3.stub:com.google.cloud.pubsub.v1.stub:com.google.cloud.speech.v1beta1.stub:com.google.cloud.speech.v1.stub:com.google.cloud.texttospeech.v1beta1.stub:com.google.cloud.trace.v1.stub:com.google.cloud.trace.v2.stub:com.google.cloud.videointelligence.v1beta1.stub:com.google.cloud.videointelligence.v1beta2.stub:com.google.cloud.videointelligence.v1.stub:com.google.cloud.videointelligence.v1p1beta1.stub:com.google.cloud.vision.v1.stub:com.google.cloud.vision.v1p1beta1.stub:com.google.cloud.vision.v1p2beta1.stub Deprecated packages